Monday, June 1, 2009

Starting a Django project in Eclipse with PyDev

Assuming python and Django installed plus eclipse with PyDev. The django project we ‘ll create is called mysite and the respective eclipse project will be named mysite-project.

  • In eclipse New –> PyDev Project
  • Project name: mysite-project
  • Deselect “Create default “src” folder and add it to the pythonpath” and press OK
  • Navigate to the Workspace folder of eclipse.
  • Navigate to the folder mysite-project from the command line.
  • Execute django-admin.py startproject mysite
  • Press F5 on the project
  • Right click on the project name in the Pydev Package Explorer from Eclipse and select "Properties".
  • Select PyDev - PYTHONPATH
  • In the "Source Folders" tab press "Add source folder" and select the folder "mysite" created from django-admin.
Now you are ready to start coding. The approach of creating the top level django project folder as a sub directory of the eclipse project's top level folder allows us to have correct auto completion from PyDev by using it's supported folder structure (a source folder inside the eclipse project). I will continue posting on my eclipse setup for django projects but this should get you started.

No comments:

Post a Comment