I'm following the Django tutorial and got stuck with an error at part 4 of the tutorial. I got to the part where I'm writing the vote view, which uses reverse to redirect to another view. For some reason, reverse fails with the following exception:
import() argument 1 must be string, not instancemethod
Currently my project's urls.py looks like this:
from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'^polls/', include('mysite.polls.urls')),
(r'^admin/(.*)', include(admin.site.root)),
)
and the app urls.py is:
from django.conf.urls.defaults import *
urlpatterns = patterns('mysite.polls.views',
(r'^$', 'index'),
(r'^(?P<poll_id>\d+)/$', 'details'),
(r'^(?P<poll_id>\d+)/results/$', 'results'),
(r'^(?P<poll_id>\d+)/vote/$', 'vote'),
)
And the vote view is: (I've simplified it to have only the row with the error)
def vote(request, poll_id):
return HttpResponseRedirect(reverse('mysite.polls.views.results', args=(1,)))
When I remove the admin urls include from the project's urls.py, i.e. making it into:
urlpatterns = patterns('',
(r'^polls/', include('mysite.polls.urls')),
#(r'^admin/(.*)', include(admin.site.root)),
)
it works.
I've tried so many things and can't understand what I'm doing wrong.