[Fixed]-No module named django.contrib.auth when using things that redirect

28👍

You are mixing up URL prefixes in your urlpatterns.

urlpatterns = patterns('karma.views',
  (r'^$', 'homepage'),
  (r'^logout/$', 'django.contrib.auth.views.logout', {'next_page': '/'}),
  (r"^opportunities/nearby$", 'draw_map'),
)

Django tries to find views relative to the given URL prefix, in your case 'karma.views'. Inside this module, there is no 'django.contrib.auth.views.logout', hence you get the ImportError.

Move the logout URL to a second block, e.g.:

urlpatterns += patterns('',
  (r'^logout/$', 'django.contrib.auth.views.logout', {'next_page': '/'}),
)

That should resolve your issue.

Leave a comment