Tutorial 5: Running Django from Eclipse

Using Django with Eclipse Tutorial: http://pydev.org/manual_adv_django.html

Lessons Learnt:

Concept 1: Django Integration in PyDev requires 3 Configurations
Screen Shot 2013-01-06 at 2.37.35 PM

Concept 2: Creating a New Django Project in Eclipse (satisfies the above 3 configurations) = django.admin.py startProject <pjname>
Screen Shot 2013-01-06 at 2.44.13 PM

Concept 3: You can also set an existing project as a Django project but manual configurations will be needed
Screen Shot 2013-01-06 at 2.47.39 PM

Concept 4: django actions can be accessed right-click project > Django = manage.py syncdb/runserver
Screen Shot 2013-01-06 at 2.57.07 PM

Concept 5: Interactive Shell w Django has Auto-Completion!
right-click project > Django > Shell with django environment

Concept 6: Running/Debugging as Django
Run: default settings has “–noreload” i.e. code changes will not be updated until next run
Run (remove –noreload): bad side effect as spawned processes are left alive in auto-reload
Run (remove –noreload + change manage.py): spawned children processes will have console outside eclipse which can be killed by Ctrl+C. See below “Run Django with autoreload”, or screen shot here:
Screen Shot 2013-01-06 at 3.45.49 PM

Screen Shot 2013-01-06 at 3.06.43 PM

Error

1. if you get an error “unresolved import: pydevd” try saving the file ‘manage.py’ first. the error should go away. 

2. If the error persists: you need to make sure pydev is in your PYTHONPATH.
a) Go to Eclipse>Preferences>PyDev>Python Interpreter:
Screen Shot 2013-01-06 at 3.49.02 PM
b) Click New Folder> (mac)”/Applications/Eclipse/plugins/org.python.pydev_x.x.x.x/pysrc”

c) Click “Apply” This adds the folder that contains pydevd.py to your PYTHONPATH. Eclipse automatically adds that to your project’s Python Library. This should resolve the problem and you can run it now.

Latest Note: Still Does Not Work. Run into errors. Need to come back and figure out HOW TO RUN WITH AUTORELOAD.

Concept 7: Use Remote Debugger to debug (allows debugging of Django projects using breakpoints)
link to use Remote Debugger

This entry was posted in Tutorials. Bookmark the permalink.

Leave a comment