Is urge cache Django pattern regex?

I am new to Django that needs help: although I am changing some URLs in my urls.py, I keep getting the same error message from Django. Here is the corresponding line from my .py settings:

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)), ) 

Therefore, I expect that whenever I am http://mydjango.yafz.org/polls/randomTest1/ , the mydjango.polls.views.randomTest1 function should run because in my polls / views .py I have the corresponding function:

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

However, I continue to receive 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 am surprised because again and again I check urls.py and no

  ^polls/randomTest/$ 

but there

  ^polls/randomTest1/' 

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

Any ideas? Why do I keep seeing the old version of regular expressions when I try to load this page even if I change my urls.py?

+4
source share
1 answer

Django compiles regular URL expressions at startup for performance reasons - reboot the server and you should see that the new URL is working correctly.

+7
source

Source: https://habr.com/ru/post/1308355/


All Articles