Good luck!
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
Jonas Geiregat
jo...@geiregat.org
在 2012年8月15日星期三,上午11:16,Sky 写道:
I've having a similar problem here using Django 1.4 and I can't quite figure what's wrong. The error reads: Could not import polls.views.index. View does not exist in module polls.views.urls.pyfrom django.conf.urls import patterns, include, urlfrom django.views.generic import DetailView, ListViewfrom polls.models import PollUncomment the next two lines to enable the admin:from django.contrib import adminadmin.autodiscover()urlpatterns = patterns('',url(r'^$',ListView.as_view(queryset = Poll.objects.order_by('-pub_date')[:5],context_object_name = 'latest_poll_list',template_name = 'polls/index.html')),url(r'^(?P<pk>\d+)/$',DetailView.as_view(model = Poll,template_name = 'polls/detail.html')),url(r'^(?P<pk>\d+)/results/$',DetailView.as_view(model = Poll,template_name = 'polls/results.html'),name='poll_results'),url(r'^(?P<poll_id>\d+)/vote/$', 'polls.views.vote'),)urlpatterns = patterns('',url(r'^polls/', include('polls.urls')),url(r'^admin/', include(admin.site.urls)),)# Uncomment the admin/doc line below to enable admin documentation:# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),views.py# Create your views here.from django.shortcuts import render_to_response, get_object_or_404from django.http import HttpResponseRedirect, HttpResponsefrom django.core.urlresolvers import reversefrom django.template import RequestContextfrom polls.models import Choice, Polldef vote(request, poll_id):p = get_object_or_404 (Poll, pk = poll_id)try:selected_choice = p.choice_set.get(pk=request.POST['choice'])except (KeyError, Choice.DoesNotExist):return render_to_response('polls/detail.html', {'poll': p,'error_message': "You didn't select a choice.",}, context_instance = RequestContext(request))else:selected_choice.votes += 1selected_choice.save()return HttpResponseRedirect(reverse('poll_results', args = (p.id,)))
--You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/bWqxut6y_YgJ.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/VTBxdWtZXTYJ.
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/handlers/base.py in get_response/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py in resolve/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py in resolve/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py in callback/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/functional.py in wrapper/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py in get_callableI've having a similar problem here using Django 1.4 and I can't quite figure what's wrong. The error reads: Could not import polls.views.index. View does not exist in module polls.views.
urls.py
from django.conf.urls import patterns, include, url
from django.views.generic import DetailView, ListView
from polls.models import Poll
Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^$',
ListView.as_view(
queryset = Poll.objects.order_by('-pub_date')[:5],
context_object_name = 'latest_poll_list',
template_name = 'polls/index.html')),
url(r'^(?P<pk>\d+)/$',
DetailView.as_view(
model = Poll,
template_name = 'polls/detail.html')),
url(r'^(?P<pk>\d+)/results/$',
DetailView.as_view(
model = Poll,
template_name = 'polls/results.html'),
name='poll_results'),
url(r'^(?P<poll_id>\d+)/vote/$', 'polls.views.vote'),
)
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/bWqxut6y_YgJ.