https://i.loli.net/2018/09/04/5b8e904239492.png 如图所示,Django 是 2.1.1 的,python3.7 请教下大佬啊,文档也看了,谷歌也谷歌到相应问题,照着改了就是没用啊。
https://i.loli.net/2018/09/04/5b8e904239492.png 如图所示,Django 是 2.1.1 的,python3.7 请教下大佬啊,文档也看了,谷歌也谷歌到相应问题,照着改了就是没用啊。
|
princelaiSep 4, 2018 via Android
1
django-admin startapp xxxx,你是这么添加 Django app 的呢
|
|
3
提示说的很明白了,你没写 app_name 啊
|
|
4
|
|
6
@xpresslink 谢谢了,确实是可以,没报错了,又出现个问题为啥不能正常显示 index.html.
|
|
7
|
|
8
@xpresslink 这个东西加在<head ></head>中么
|
|
9
显示 404 ?你可以把你的 urls 和 views 贴上来,根据你目前提供的信息无法判断
|
|
10
|
|
12
@xpresslink 这个解决了,404 不见了。出现了这个 Not Found
The requested URL / was not found on this server.。 我不太知道创建了一个简单的 index.html,这个反解析要放在那里。 |
|
13
@xpresslink 这个错误好像和反解析没关系吧,因为并没有用到 URL
|
|
SankoSep 4, 2018 via Android
14
你现在是首页要显示一个已经写好的 html 文件是吗?你可以去搜下 render 函数
|
|
15
@Sanko 好的,我是按那书上做的。也许是因为版本不同,有些东西用的不太一样。我明天在看看文档。看是不是 render 用法变了。
|
|
RBQMTSep 5, 2018
17
path('about_us/',views.about_us, name='about_us'),上面例子不太好,这样
|
|
xpresslinkSep 5, 2018
18
@shonky
最省事的办法 然后在 urlpatterns 中最上面加一行 path('', TemplateView.as_view(template_name="index.html"), name="index"), |
|
xpresslinkSep 5, 2018
19
在 learning_notes 下的 urls 开头加一行
from django.views.generic import TemplateView |
|
PulpFunctionSep 5, 2018
20
上 git 看看 demo 啥的
|
|
22
@PulpFunction 看 demo 样例是叫我去看看别人优秀的源码么。还是怎么个意思 。
|
|
23
@xpresslink 好的,晚上回去试试。谢谢大佬抽空解答。
|
|
metamaskSep 5, 2018
24
app_name = getattr(urlconf_module, 'app_name', app_name)
if namespace and not app_name: raise ImproperlyConfigured( 'Specifying a namespace in include() without providing an app_name ' 'is not supported. Set the app_name attribute in the included ' 'module, or pass a 2-tuple containing the list of patterns and ' 'app_name instead.', ) @shonky 你点进去 include 可以看到这个; 你设置 namespace 相对应在 include 的 urls 也需要设置 app_name ; url reverse 的时候也必须加上去: 如"namespace:route" 或者 "app_name:route"; 相同的情况下,默认优先匹配第一个; |
|
26
@xpresslink 大佬,按你的改了。网页报错 Server Error (500)
|
|
xpresslinkSep 5, 2018
27
|