On Sep 17, 10:13 am, bruno desthuilliers
<bruno.desthuilli...@gmail.com> wrote:
> On 16 sep, 18:06, cool-RR <ram.rac...@gmail.com> wrote:
>
> > Hello!
>
> > There's something that's bothering me:
>
> > When developing a Django application, what is `sys.path` supposed to
> > contain? The directory which contains the project, or the directory of
> > the project, or both?
>
> sys.path always starts with the directory where the current script
> lives - so when running './manage.py runserver', sys.path will always
> starts with your project's directory. This is teh default Python
> behaviour. Also and IIRC, django adds the project's parent directory
> to sys.path too.
>
> > What led me to this question is a failure when using
> > `urlresolvers.reverse`. It's giving me a `NoReverseMatch` error, and
> > it seems that the reason is that there are two different versions of
> > my view function; One with a `__module__` of `my_app.views` and one
> > with a `__module__` of `my_project.my_app.views`.
>
> I bet you have a full import (=> 'myproject.my_app.views') somewhere
> in your sources.
>
> As far as I'm concerned, I *never* use any reference to the project's
> package in my imports - this gives much more flexibility (you can
> rename your project's directory, move apps outside the project's
> directory etc without having to update all your imports). The only
> caveat is that, when deploying with mod_wsgi, you have to make sure
> you add the project's directory itself to sys.path (which is no bige
> deal).

Bruno, look at this line in `django/core/management/__init__.py`:

    project_module = import_module(project_name)

It's importing the project. Isn't this a problem? I mean, every object
obtained from the imported project will be different from its
counterpart which was imported through an app. So what's going on?


Ram.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to