Enter code here...from django.shortcuts import render
from django.template import RequestContext, loader
from django.http import HttpResponse
from polls.models import Poll
def index(request):
latest_poll_list = Poll.objects.get(name="Test") #Poll.objects.all().order_by('-pub_date')[:5] context = {'latest_poll_list': latest_poll_list}
return render(request, 'polls/index.html', context)
def detail(request, poll_id):
try:
poll = Poll.objects.get(pk=poll_id)
except Poll.DoesNotExist:
raise Http404
return render(request, 'polls/detail.html', {'poll': poll})
def results(request, poll_id):
return HttpResponse("You're looking at the results of poll %s." % poll_id)
def vote(request, poll_id):
return HttpResponse("You're voting on poll %s." % poll_id)
latest_poll_list = Poll.objects.get(name="Test")
def index(request):
latest_poll_list = Poll.objects.get(name="Test").id #Poll.objects.all().order_by('-pub_date')[:5]
context = {'latest_poll_list': latest_poll_list}
return render(request, 'polls/index.html', context)
FieldError at /polls/
Cannot resolve keyword 'name' into field. Choices are: choice, id, pub_date, question
Request Method: GET Request URL: http://127.0.0.1:8000/polls/ Django Version: 1.6.5 Exception Type: FieldError Exception Value: Cannot resolve keyword 'name' into field. Choices are: choice, id, pub_date, question
Exception Location: /usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py in names_to_path, line 1283 Python Executable: /usr/bin/python Python Version: 2.7.6 Python Path: ['/home/michael/workspace/new/mysite',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PILcompat',
'/usr/lib/python2.7/dist-packages/gst-0.10',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client']
Server time: Sat, 2 Aug 2014 19:20:54 +0000
What does the error say?
Perhaps you should show your model definition and the complete traceback.
A wild guess though, did you syncdb?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3af5d757-f76c-40ac-ab54-f2ff64aa69c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.