Django错误网址.py

2024-06-01 12:23:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我在尝试设置django项目时遇到问题:

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

我得到了下一个错误:

^{pr2}$

更新: 那是个错误,谢谢。在

现在,我得到了一个错误:

Exception Value:
No module named about

谢谢你第一次帮我


Tags: 项目djangofromimporturlincludeadminconf
2条回答

将包含的url文件路径用引号括起来:

url(r'^admin/', include('webshop.admin.site.urls')),

当您没有定义任何要计算的名称的名称时,将显示NameError。在

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.

因此,此代码将导致NameError在分配给a的第二行抛出:

def foo():
    a = 1
    b = 2
    a = c + (a * b)

为了解决您的问题,您可能应该在引用代码之前将import webshop添加到代码中使用带引号的字符串,如this example in the django docs。在

相关问题 更多 >