Does Django cache url regex patterns somehow?

Posted by Emre Sevinç on Stack Overflow See other posts from Stack Overflow or by Emre Sevinç
Published on 2010-04-29T12:53:10Z Indexed on 2010/04/29 12:57 UTC
Read the original article Hit count: 760

Filed under:
|
|

I'm a Django newbie who needs help: Even though I change some urls in my urls.py I keep on getting the same error message from Django. Here is the relevant line from my settings.py:

ROOT_URLCONF = 'mydjango.urls'

Here is my urls.py:

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Example:
    # (r'^mydjango/', include('mydjango.foo.urls')),

    # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
    # to INSTALLED_APPS to enable admin documentation:
    #(r'^admin/doc/', include(django.contrib.admindocs.urls)),

    # (r'^polls/', include('mydjango.polls.urls')),
    (r'^$', 'mydjango.polls.views.homepage'),
    (r'^polls/$', 'mydjango.polls.views.index'),
    (r'^polls/(?P<poll_id>\d+)/$', 'mydjango.polls.views.detail'),
    (r'^polls/(?P<poll_id>\d+)/results/$', 'mydjango.polls.views.results'),
    (r'^polls/(?P<poll_id>\d+)/vote/$', 'mydjango.polls.views.vote'),
    (r'^polls/randomTest1/', 'mydjango.polls.views.randomTest1'),
    (r'^admin/', include(admin.site.urls)),
)

So I expect that whenever I visit http://mydjango.yafz.org/polls/randomTest1/ the mydjango.polls.views.randomTest1 function should run because in my polls/views.py I have the relevant function:

def randomTest1(request):
    # mainText = request.POST['mainText']
    return HttpResponse("Default random test")

However I keep on getting the following error message:

Page not found (404)
Request Method:     GET
Request URL:    http://mydjango.yafz.org/polls/randomTest1

Using the URLconf defined in mydjango.urls, Django tried these URL patterns, in this order:

   1. ^$
   2. ^polls/$
   3. ^polls/(?P<poll_id>\d+)/$
   4. ^polls/(?P<poll_id>\d+)/results/$
   5. ^polls/(?P<poll_id>\d+)/vote/$
   6. ^admin/
   7. ^polls/randomTest/$

The current URL, polls/randomTest1, didn't match any of these.

I'm surprised because again and again I check urls.py and there is no

 ^polls/randomTest/$

in it, but there is

 ^polls/randomTest1/'

It seems like Django is somehow storing the previous contents of urls.py and I just don't know how to make my latest changes effective.

Any ideas? Why do I keep on seeing some old version of regexes when I try to load that page even though I changed my urls.py?

© Stack Overflow or respective owner

Related posts about python

Related posts about django