I have a problem trying to setup django project:
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/', include(webshop.admin.site.urls)),
url(r'^about/', include(webshop.views.about)),
url(r'^products/', include(webshop.views.available_products)),
url(r'^products/(\d+)/', include(webshop.views.productview)),
and I get the next error:
Exception Type: NameError
Exception Value:
name 'webshop' is not defined
Exception Location: /home/Python/myProject/myProject/urls.py in <module>, line 11
UPDATE: Thanks, it was nub, mistake.
Now, I'm getting this error:
Exception Value:
No module named about
Thanks for help, it my first time using django
将包含的网址文件路径用引号引起来:
url(r'^admin/', include('webshop.admin.site.urls')),
NameError shows up when you've not defined a name -- any name that you're trying to evaluate.
Raised when a local or global name is not found. This applies only to unqualified names. The associated value is an error message that includes the name that could not be found.
So this code would cause NameError
to be thrown at the second line assigning to a
:
def foo():
a = 1
b = 2
a = c + (a * b)
In order to fix your problem, you should probably
add an
use quoted strings, as in this example in the django docs . import webshop
to your code before you reference it
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.