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?

I'm getting a syntax error: EOL while scanning string literal url(r'^$, views.hello_world), I did it correctly!!!

from django.conf.urls import url from django.contrib import admin

from . import views

urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^$, views.hello_world), ]

Afloarei Andrei
Afloarei Andrei
5,163 Points

I'm not sure, but, I think that you are missing a ' in the second url.

2 Answers

urls.py

from django.contrib import admin
from django.urls import path

from . import views

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', views.hello_world),
]

Note: I am using Python3, and Django 2.0.3

You need to make the following import. It does not appear to be standard in urls.py as of the current version:

from django.conf.urls import url, include

Then your code should work.