MyProj/myproj/urls.py:
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^accounts/login/$', 'django.contrib.auth.views.login'),
url(r'^accounts/logout/$', 'django.contrib.auth.views.logout_then_login'),
url(r'^admin/', include(admin.site.urls)),
url(r'^', include('apps.data.urls')),
)
MyProj/apps/data/urls.py:
from django.conf.urls import patterns, url
urlpatterns = patterns('',
url('^tasks/sync_database/', 'apps.data.views.sync_database'),
)
MyProj/apps/data/views.py:
from .tasks import sync_database as sync_database_task
from django.shortcuts import redirect
def sync_database(request):
sync_demand_stacks_task()
return redirect('/')
The task takes about 5 minutes to run. I expect that when I visit the url localhost:8000/tasks/sync_database/
that the web page should block for the duration of the time it takes the task to run, then show me the home page at url localhost:8000/
.
This does happen, but instead of running the task just once it runs it twice. What gives?
EDIT: I see this output in the console at the very end of the first request:
127.0.0.1 - - [20/Feb/2014 15:18:43] "GET /tasks/sync_database/? HTTP/1.1" 500 -
I'm wondering where this URL with a question mark appended comes from.
Getting my favicon to work correctly has apparently made the problem disappear.
MyProj/myproj/urls.py:
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^accounts/login/$', 'django.contrib.auth.views.login'),
url(r'^accounts/logout/$', 'django.contrib.auth.views.logout_then_login'),
url(r'^admin/', include(admin.site.urls)),
url(r'^', include('apps.data.urls')),
)
MyProj/apps/data/urls.py:
from django.conf.urls import patterns, url
urlpatterns = patterns('',
url('^tasks/sync_database/', 'apps.data.views.sync_database'),
)
MyProj/apps/data/views.py:
from .tasks import sync_database as sync_database_task
from django.shortcuts import redirect
def sync_database(request):
sync_demand_stacks_task()
return redirect('/')
The task takes about 5 minutes to run. I expect that when I visit the url localhost:8000/tasks/sync_database/
that the web page should block for the duration of the time it takes the task to run, then show me the home page at url localhost:8000/
.
This does happen, but instead of running the task just once it runs it twice. What gives?
EDIT: I see this output in the console at the very end of the first request:
127.0.0.1 - - [20/Feb/2014 15:18:43] "GET /tasks/sync_database/? HTTP/1.1" 500 -
I'm wondering where this URL with a question mark appended comes from.
Getting my favicon to work correctly has apparently made the problem disappear.
0 commentaires:
Enregistrer un commentaire