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 trialTony Ahn
24,417 PointsCan't get hello world to show up
Hi,
https://teamtreehouse.com/library/django-basics/what-a-view/what-are-urls This is the video I am on
I have done exactly what the video has told me to do:
The only difference is that I have a django environment set up at c9.io
in my url.py I have:
from django.conf.urls import url, include from django.contrib import admin
from . import views
urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^$', views.hello_world), ]
and in my views.py I have: from django.http import HttpResponse
def hello_world(request): return HttpResponse("Hello World")
However when I save the files and run the server, I still get the default "It work! Congratulations on your first Django-powered page.", instead of Hello World.
I'm not sure what I have to do to make this work!
1 Answer
Haydar Al-Rikabi
5,971 PointsSeems to me like the latest version of Django 2.0 does not accept r'^$' for an empty string. Try r'' in your urls.py This will resolve your issue.
Vasileios Koukoutsas
13,864 PointsThank you, Haydar! I had the same issue with the newest version of Django. Your suggestion solved the issue!
Sam Fellows
3,968 PointsSam Fellows
3,968 PointsThe same thing happens to me too. Were you able to solve it?