0

I am trying to add a few urls in my urls.py.

urls.py

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'Permissions.views.home', name='home'),
    # url(r'^Permissions/', include('Permissions.foo.urls')),
     #url(r'^Permissions$', include('Permissions.Authenication.urls')),
     url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
     url(r'^admin/', include(admin.site.urls)),
     url(r'^$',RedirectView.as_view(url='/welcome/'),
)

urlpatterns += patterns('',
     url(r'^register/$', 'drinker.views.DrinkerRegistration',name='DrinkerRegistration'),
     url(r'^welcome/$','drinker.views.DrinkerWelcome',name='DrinkerWelcome'),
     url(r'^home/(?P<userpk>[^/]+)/$','drinker.views.DrinkerHome',  name='DrinkerHome'),     
)

Error:

Traceback:
File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  101.                             request.path_info)
File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve
  298.             for pattern in self.url_patterns:
File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/core/urlresolvers.py" in url_patterns
  328.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/core/urlresolvers.py" in urlconf_module
  323.             self._urlconf_module = import_module(self.urlconf_name)
File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/utils/importlib.py" in import_module
  35.     __import__(name)

Exception Type: SyntaxError at /
Exception Value: invalid syntax (urls.py, line 17)

Not sure where the error is... Need some help...

1
  • your missing a bracket here - url(r'^$',RedirectView.as_view(url='/welcome/'), Commented Aug 31, 2012 at 14:00

1 Answer 1

6

You're missing a parenthesis and have an extra comma:

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'Permissions.views.home', name='home'),
    # url(r'^Permissions/', include('Permissions.foo.urls')),
    # url(r'^Permissions$', include('Permissions.Authenication.urls')),

    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', RedirectView.as_view(url='/welcome/')) #Error was here
)

You have another trailing comma in your second half:

urlpatterns += patterns('',
    url(r'^register/$', 'drinker.views.DrinkerRegistration',name='DrinkerRegistration'),
    url(r'^welcome/$','drinker.views.DrinkerWelcome',name='DrinkerWelcome'),
    url(r'^home/(?P<userpk>[^/]+)/$','drinker.views.DrinkerHome', name='DrinkerHome') # Comma was here     
)
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.