As others have pointed out, the reason putting it in settings.py causes it
to be run twice is because settings is loaded twice when you use runserver.
That won't happen in production, however, as the mod_wsgi binding doesn't
require the "other" process when it's deployed through the wsgi interface.
I think if you put it in urls.py it should run (once) just before the first
request.
On Thursday, July 31, 2014 10:30:08 AM UTC-4, ke1g wrote:
>
> It runs twice because runserver uses two processes: the real server, and;
> the monitoring process that restarts the other when you change a source
It runs twice because runserver uses two processes: the real server, and;
the monitoring process that restarts the other when you change a source
file. You could fool around with undocumented internals to figure out which
a given import is running in. Or you could use a modifies runserver
command.
On 31/07/2014 5:57 AM, Chen Xu wrote:
Hi Everyone:
I would like to call a function when my project starts, basically I want
to call a do_something() when I run python manage.py runserver. However,
when I put it into settings.py, it gets called twice, but I only want it
to execute once.
Is there
I am running 1.6.2
On Wed, Jul 30, 2014 at 4:02 PM, aRkadeFR wrote:
> Which version of Django are you running?
>
> On 30/07/14 15:46, Chen Xu wrote:
> > Hi Everyone:
> > I would like to call a function when my project starts, basically I want
> to
> > call a do_something() when I run python man
Which version of Django are you running?
On 30/07/14 15:46, Chen Xu wrote:
> Hi Everyone:
> I would like to call a function when my project starts, basically I want to
> call a do_something() when I run python manage.py runserver. However, when
> I put it into settings.py, it gets called twice, bu
6 matches
Mail list logo