0

I am learning django and started to watch some tutorials, when I add url() function to urls.py, it gives an invalid syntax error

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

url(r'^admin/', admin.site.urls),
      ^
SyntaxError: invalid syntax
2
  • 8
    You're missing a comma after the first pattern. Commented Jan 16, 2019 at 11:12
  • As a general rule: in the case of a SyntaxError, the line the error message points too is the line where the syntax error is detected, which is not necessarily the faulty line - most often, the problem is in one of the previous lines. Commented Jan 16, 2019 at 12:04

1 Answer 1

1

You're missing a comma after your first url() ("home") in the list. You'll want:

url(r'^$', views.home, name='home'),

Also, if you are just learning, consider using Django 2.1 with it's simplified URL syntax. Good luck!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.