orbit6781
orbit6781

Reputation: 1

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

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

Upvotes: 0

Views: 567

Answers (2)

Aiatokko
Aiatokko

Reputation: 1

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

Upvotes: 0

Rob Bricheno
Rob Bricheno

Reputation: 4653

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.

Upvotes: 1

Related Questions