Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django Basics What a View! What Are URLs?

url vs path

I am using Django 2.1.4 and when it generates the urls.py file, instead of a:

url(r'admin/', admin.site.urls),

it generates something like this:

path('admin/', admin.site.urls).

So, when I follow along with the video on my computer, path("", views.hello_world) is what works, not the regular expression. Any idea why the newer version of Django uses path instead of url?

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

Sure seems a lot easier to use the new path. The old way is still available.

Check out this SO Post for some info.

1 Answer

Simbarashe,

path is just easier overall, which is why django decided to go with it as it's default I believe. If you would like to follow along with the regular expression paths, from django.urls import re_path is the same function that the old url was. https://stackoverflow.com/questions/47947673/is-it-better-to-use-path-or-url-in-urls-py-for-django-2-0