TAGS :Viewed: 7 - Published at: a few seconds ago

[ Can't identify Django error ]

Seeing the following syntax error, but the urls.py file seems to be correct. What am I missing?

SyntaxError at /admin/
invalid syntax (urls.py, line 6)
Request Method: GET
Request URL:    http://127.0.0.1:8000/admin/
Django Version: 1.4.1
Exception Type: SyntaxError
Exception Value:    
invalid syntax (urls.py, line 6)
Exception Location: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py in import_module, line 35
Python Executable:  /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Python Version: 2.7.2

Here's the urls.py:

from django.conf.urls.defaults import *
from events import views

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    (r'^events/', include('events.urls')),
    (r'^admin/', include(admin.site.root)),
)

...

from django.conf.urls.defaults import *
from events import views

urlpatterns = patterns('',
    url(r'^create/$', views.create, name='ev_create')
    url(r'^tonight/$', views.tonight, name='ev_tonight'),   
)

Answer 1


You are missing a comma:

urlpatterns = patterns('',
    url(r'^create/$', views.create, name='ev_create')     # <-- comma missing
    url(r'^tonight/$', views.tonight, name='ev_tonight'),   
)

Note that this is on line 5 of your urls.py module, but Python could only discover this on line 6 when it encountered something that doesn't fit after your url(...) call.