0

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

0

2 Answers 2

1

Wrap your included url file paths in quotes:

url(r'^admin/', include('webshop.admin.site.urls')),
Sign up to request clarification or add additional context in comments.

Comments

0

NameError shows up when you've not defined a name -- any name that you're trying to evaluate.

From the docs:

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 import webshop to your code before you reference it use quoted strings, as in this example in the django docs.

1 Comment

Normally, yes, but include doesn't expect an imported module - it takes a path to import. Or some other options, but for this use case it needs to be a path string. Well, actually, the docs are ambiguous now that I look at it - "URLconf module (or module name)". So maybe a full import webshop.admin.site.urls would work. docs.djangoproject.com/en/dev/ref/urls/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.