0

I am trying to build a website with Django. I am new to Django and have followed the Tango with Django tutorial. I keep getting an URlconf error I do not understand. I have a domain (www.example.com), an app (mainApp) and two views in mainApp (homePage, registration). I want

  1. http://www.example.com to be matched with the homePage view
  2. http://www.example.com/registration/ to be matched with the registration view.

My urls.py file for the project is

from django.conf.urls import patterns, include, url
from django.contrib import admin

urlpatterns = patterns(
    '',
    url(r'^admin/', include(admin.site.urls)),
    url(r'^', include('mainApp.urls')),
)

The urls.py file for mainApp is

from django.conf.urls import patterns, url
from mainApp import views

urlpatterns = patterns(
    '',
    url(r'^$', views.homePage, name='homePage'),
    url(r'^registration/$', views.registration, name='registration'),
)

This configuration displays the homePage view correctly, but not the registration view. The error is:

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

    ^admin/
    ^$
    ^/

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

What causes the error?

user4422
  • 278
  • 3
  • 11

1 Answers1

1

It looks fine. If you're hosting it online you should restart the webapp, if hosting it locally then restart the local host. Without restarting it the changes don't register.

Meghdeep Ray
  • 5,262
  • 4
  • 34
  • 58
  • I have restarted for the (probably) fourth time and now it works. How is that possible? (I am on pythonanywhere) – user4422 May 07 '15 at 08:50
  • PythonAnywhere is a great site ! Thing is when you make changes, you have to restart for the changes to go live. The server can't just suddenly integrate it when it's already working. When it restarts then it uses those settings to restart. Which makes troubleshooting and debugging a pain sometimes but thats how it is. Just leave the Webs tab open so that you can quickly restart the server whenever you make changes that you want to test. – Meghdeep Ray May 07 '15 at 08:52
  • Still it did not work at the first, second and third restart. Maybe I did something wrong. Anyway, I agree that Pythonanywhere is great. – user4422 May 07 '15 at 09:02
  • It sometimes takes a bit of time for it to get up and running especially if you're on a free account. The server processing speed isn't too great on the free accounts. – Meghdeep Ray May 07 '15 at 09:04