Saturday, February 18, 2012

Eclipse + Django + SVN (Visual SVN)

I wasted tons of time trying to figure out how to add a project to SVN. I wasn't sure whether I should create the django project in CMD as usual then import those files manually to Ecipse and then..... and then.......confusion galore!

Anyways, here is one way it works.

NOTE: This guide assumes that you've already Installed Eclipse, Python and integrated Django to it and Visual SVN. If not, try and do that then come back to this.

Create a normal project in Eclispse but select PyDev Django Project
 

Enter the Project Name and select the Version of Python you'll be using:


In Django Settings, Enter the details of your database connection and click on Finish:
 



Your project appears in your Package Explorer:





Now Go to Visual SVN. Ensure that the status is Running.

Right click on the "Repositories" Node and select "Create new Repository". Enter a name and Select the Check box that will create a default structure then click ok.

Your project's repository now appears in your Repositories browser










Now go back to Eclipse and right click on your project. Select Team--Share Project:
Select SVN from the "Share Project" Window that appears


From the "Share Project with SVN Repository" window, select the "Create a new repository location":


Enter the URL of your repository. Now to do this, go back to Visual SVN, right click on your project and select "Copy URL to clipboard".
Go back to Eclipse and paste that URL in the URL field and click Finish:


You might get a window asking you about "Confirm Open Perspective" If you are not very familiar with Eclipse then I suggest you say NO as it will change the way things look and you don't want that as a rookie.

Now your Project is in SVN:



Notice the question marks on your files.

Right click on your project and select "Team--Commit": Enter a comment and click ok to make your first commit to SVN.

 Now check out your Package explorer and notice the change in icons:



Hope this saves you a few minutes of your life! Now off to explore Django.