I just noticed another thing here. But, it could just be related to copying
and pasting your source here. See below

On Tue, Aug 14, 2012 at 11:16 PM, Sky <a.technicolor.s...@gmail.com> wrote:

> 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.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:
>

So, first, add a # to the beginning of that line, to make it this:
# Uncomment the next two lines to enable the admin:


> from django.contrib import admin
> admin.autodiscover()
>
>
Here, you're going to make a list of patterns. Nothing wrong with that.


> 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'),
> )
>
>
Now, below, you've overridden the same URL patterns. (The previous list
should, hypothetically, be ignored at this point) This is actually reading
the urls.py file from your 'polls' module. I'm not sure if this is really
all in the same file or not. If it is, can you show us what's in your
polls/urls.py file?


> 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_404
> from django.http import HttpResponseRedirect, HttpResponse
> from django.core.urlresolvers import reverse
> from django.template import RequestContext
> from polls.models import Choice, Poll
>
> def 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 += 1
>                 selected_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.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to