我正在尝试使用Django 1.11,我遇到了一个问题:
我的文件agora / agora / urls.py:
from django.conf.urls import url, include
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^start/', include('start.urls', namespace='start')),
]
这是我的文件agora / start / urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', view_first, name='view_first'),
url(r'^/inscription', view_second, name='view_second'),
url(r'^/about', view_about, name='view_about'),
]
Django服务器返回错误:
NameError:未定义名称“view_first”
非常感谢你的回答!
答案 0 :(得分:2)
你应该对所有功能都这样做
You have not accepted the license agreements of the following SDK components:
[Android SDK Build-Tools 25, Android SDK Platform 25]
答案 1 :(得分:0)
您必须在import
语句
from django.conf.urls import url
from .views import view_first, view_second, view_about
urlpatterns = [
url(r'^$', view_first, name='view_first'),
url(r'^/inscription', view_second, name='view_second'),
url(r'^/about', view_about, name='view_about'),
]
或导入视图并使用view.
from django.conf.urls import url
from . import view
urlpatterns = [
url(r'^$', view.view_first, name='view_first'),
url(r'^/inscription', view.view_second, name='view_second'),
url(r'^/about', view.view_about, name='view_about'),
]
答案 2 :(得分:0)
虽然这个问题已经得到解答,但我确实注意到了一个小问题,但错误。
在撰写网址时,添加" $"始终建议在端点末尾使用符号。不添加相同的URL可能导致类似URL的重叠,这可能会混淆应用程序行为甚至可能导致一些严重错误。 美元符号标志着网址字符串的结束。
只是抬头!!