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?

Use of regex in this video? Where is re being imported? and why r'^$' rather than r'' ?

I am not seeing where the re module is being imported in either views.py or urls.py- does it not need to explicitly be imported?

Also, Kenneth uses url(r'^$', views.hello_world) in the urls.py file. Would url(r'', views.hello_world) not be correct? I tried both with the same results.

1 Answer

Haydar Al-Rikabi
Haydar Al-Rikabi
5,971 Points

I believe r'' is a python statement, not a Django-specific module. That's why you don't need to import it. Also, r'' is the same as r'^$' because the base url of your site does not have anything that comes after it. I hope this answer your question.