Skip to content
Advertisement

Django urls.py issue, not sure what to put in ‘urlpatterns’

I’ve been following this tutorial (Django Tutorial Part 3) and I’ve stumbled across what I’m assuming is a syntax issue between the time this tutorial was written and the new Django releases. My admin page loads just fine.

Code Block in Question So in the picture linked, that is the area that I am having trouble with from the tutorial. I think my “mysite/urls.py” file is fine, but the “polls/urls.py” file is where I’m not sure what to put.

Below is what mysite/urls.py looks like:

JavaScript

And here is what my polls/urls.py looks like:

JavaScript

Advertisement

Answer

but the polls/urls.py file is where I’m not sure what to put.

The empty string (''), so:

JavaScript

We can inspect how the path is compiled to a regex with:

JavaScript

The pattern is thus compiled to a regex ^$, which is the same as the regex for the url pattern in the documentation.

Advertisement