问题
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