[wingide-users] Importing Django project

Wingware Support support at wingware.com
Fri Sep 17 09:02:00 MDT 2010

cool-RR wrote:
> Check out this thread on Django-users, specifically message number 2 
> by Bruno:
> http://groups.google.com/group/django-users/browse_thread/thread/eb9bef1f181980c0#
> If what he's saying is true, then importing by project name (`import 
> my_project.views` instead of `from . import views`) is something that 
> can lead to problems like that which was described in the first message.
> I'm suspecting that Wing does that, because it sets the environment 
> variable `DJANGO_SETTINGS_MODULE` to be `my_project.settings`.
> What do you think?

I think you're correct there is something slightly odd here but I didn't 
yet go through Django in detail to investigate it.  What happened with 
my initial implementation of scripts/django.py in Wing 4.x was that I 
was just adding the directory enclosing the project to the Python Path 
and setting the above env.  However, it turned out there were problems 
unless I _also_ added the directory of the project to the Python Path to 
make the various possible import forms work right, as far as our source 
analysis being able to find things.  I did not get further than that for 
lack of time and decided to wait to see if problems arose.

I personally think imports should be very carefully standardized so 
things are found only one way and there's no import magic (which I 
suspect there is in Django, just haven't had time to trace through 
this).  I'm not happy adding both parent directory of a project and the 
project directory to Python Path but I didn't see any alternative given 
the behavior I was observing in Django.

Note that if you're able to get things working in Django with just one 
or the other directory on sys.path you can easily remove the other from 
Project Properties in Wing.  It only gets added there when you set up 
your project for Django initially.


Stephan Deibel
Wingware | Python IDE
Advancing Software Development


More information about the wingide-users mailing list