Sunday, August 28, 2011

Re: why is settings.py executed twice?

Best answer is here ...

http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html

M


On 28/08/2011 11:02am, Gelonida N wrote:
> Hi,
>
> This is also one of the things (I just started using django, so I have
> still quite many questions) , that I don't really understand.
>
> It doesn't break anything and I am not stuck.
> I'd just like to understand.
>
>
>
> $ django-admin startproject settings_twice
> $ echo 'print "SOMETEXT"'>> settings.py
> $ ./manage.py shell
>
> The output, that I get is
> SOMETEXT
> SOMETEXT
>
> In [1]:
>
>
> So it seems settings.py is executed twice.
>
> I would have expected, that settings.py is imported multiple times.
> What I thought though is, that a module is normally only executed once
> during the first import
> and that subsequent imports do not execute settings.py anymore.
>
> It seems even, that all modules imported by settings.py are executed twice.
>
> Is ./manage.py shell starting two processes??
>
> If yes, why wasn't settings.py imported before 'forking' ?
>
> Thanks a lot in advance
>
>
>
>
>

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

No comments:

Post a Comment