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?

Tony Ahn
Tony Ahn
24,417 Points

Can'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!

Sam Fellows
Sam Fellows
3,968 Points

The same thing happens to me too. Were you able to solve it?

1 Answer

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

Seems 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
Vasileios Koukoutsas
13,864 Points

Thank you, Haydar! I had the same issue with the newest version of Django. Your suggestion solved the issue!