I am learning to build a Django app named rango from the site http://www.tangowithdjango.com/ , but things are bit different as I am using Django 1.9 which is not same as in the tutorial, so I am facing difficulty in running the app. Whenever I run the server, it gives error as
NameError: name 'rango' is not defined
I have included rango in the INSTALLED_APPS list. Here is my master urls.py file's code:
from django.conf.urls import include,url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^rango/', include(rango.urls)),
]
And here is my local urls.py file (rango's urls.py) that is kept within the /rango folder:
from django.conf.urls import patterns, url
from rango import views
urlpatterns=patterns('',
url(r'^$',views.index,name='index'),)
So why is my rango app not being located?
This is happening because the rango.urls
has to be in quotes. So your master urls.py
should look like this -
from django.conf.urls import include,url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^rango/', include('rango.urls')),
]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.