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!
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
We need to add a URL for the view we created in the last challenge - was that hello_world view?
This task seems very unclear for me.
from django.conf.urls import url import views urlpatterns = [ url(r'^/$', views.hello_world) ]
Chris FreemanTreehouse Moderator 68,389 Points
See commented code below.
from django.conf.urls import url # Task 1 of 2: First, though, import the views module from the current # directory. Remember, the current directory is referenced as a single # dot or period. from . import views # Task 2 of 2: Now we need to make a url for our index view. Add a url # to urlpatterns with a pattern for an empty string that points to the # index view from views. # The empty string regex can be represented using the start ('^') and # ('$') anchors: r'^$'. The index view is found in the imported module # 'views' using 'views.index' urlpatterns = [ url(r'^$', views.index) ]
Iain SimmonsTreehouse Moderator 32,303 Points
The first task of the challenge just asks you to 'import the
views module from the current directory'. Once you do that, the next task will give you more detail on how to create the URL.
Ary de Oliveira28,298 Points
1 =from . import views
2 = url(r'^$', views.index)
Patric Daniel Pförtner1,542 Points
You are very close to the answer, here is how I did it:
from django.conf.urls import url from . import views urlpatterns = [ ]
Why are you learning Python? Maybe we have the same aims! I am learning it to bring my Start UP www.wolf-gate.com to the next level. Thank´s to Kenneth Love it´s easily possible :)