What is incorrect with my urls.py file? Chapter 18 of Python Crash Course

梦想与她 提交于 2020-02-06 08:21:27

问题


Why does the python code below crash my website?

But the code at the very bottom does not crash the website

Here is the code that crashes the website:

from django.urls import path, include
from django.contrib import admin

urlpatterns = [ 
     path('admin/', admin.site.urls), 
     path('', include('learning_logs.urls')),
]

Here is the code that does not crash:

from django.contrib import admin
from django.urls import path

urlpatterns = [
    path('admin/', admin.site.urls),
]

Thank you


回答1:


You have a space between url and patterns. It should be all one word urlpatterns.

If you ever need to check the code for any of the other exercises in that book, they're all on github here.




回答2:


I got to this point in the Crash Course, this area will break your site, temporarily. You will not have made all the files referenced in your code yet. In this case, you haven't made the urls.py file in learning_logs. After this is made, you will not have updated your views.py nor made your index.html template. Keep going, it should be resolved later. See also: https://ehmatthes.github.io/pcc/chapter_18/README.html#updates



来源:https://stackoverflow.com/questions/50547218/what-is-incorrect-with-my-urls-py-file-chapter-18-of-python-crash-course

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!