going through the django tutorial i found error while executing the python manage.py runserver.The error is attached below

275 views
Skip to first unread message

Avitab Ayan Sarmah

unread,
May 6, 2018, 3:05:25 PM5/6/18
to Django developers (Contributions to Django itself)
views.py:

from django.shortcuts import get_object_or_404, render

from . models import Question

def index(request):
latest_question_list = Question.objects.order_by('-pub_date')[:5]
context = {'latest_question_list': latest_question_list}
return render(request, 'polls/index.html', context)

def detail(request, question_id):
question = get_object_or_404(Question, pk=question_id)

def results(request, question_id):
response = "You're looking at the results of question %s."
return HttpResponse(response % question_id)

def vote(request, question_id):
return HttpResponse("You're voting on question %s." % question_id)

detail.html:

<h1>{{ question.question_text }}</h1>
<ul>
{% for choice in question.choice_set.all %}
  <li>{{ choice.choice_text }}</li>
{% endfor %}
</ul>

index.html:

{% if latest_question_list %}
  <ul>
  {% for question in latest_question_list %}
    <li><a href="/polls/{{ question.id }}/">{{
question.question_text }}</a></li>
  {% endfor %}
  </ul>
{% else %}
  <p>No polls are available.</p>
{% endif %}

mysite/polls/urls.py:

from django.urls import path

from . import views

urlpatterns = [
# ex: /polls/
path('', views.index, name='index'),
# ex: /polls/5/
path('<int:question_id>/', views.detail, name='detail'),
#ex: /polls/5/results/
path('<int:question_id>/results/', views.results, name='results'),
#ex: /polls/5/vote/
path('int:question_id>/vote/', views.vote, name='vote'),
]

mysite/urls.py:

from django.contrib import admin
from django.urls import include, path

urlpatterns = [
path('', include('polls.urls')),
path('admin/', admin.site.urls),
]


please check these codes and comment where i've gone wrong
Capture4.PNG

Jani Tiainen

unread,
May 6, 2018, 3:15:27 PM5/6/18
to django-d...@googlegroups.com
Hi.

You have a typo in your models.py

It should be ForeignKey not Foreignkey. Note the capital K.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/935bc46e-469f-4a60-882c-8c8c32cc85fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pradeep Sharma

unread,
May 8, 2018, 8:38:50 AM5/8/18
to Django developers (Contributions to Django itself)
check your models.py 

Adam Johnson

unread,
May 8, 2018, 10:17:14 AM5/8/18
to django-d...@googlegroups.com
For future ref: this mailing list is for the development of Django itself, not for support. Use the django-users mailing list for that, or IRC #django on freenode, or a site like Stack Overflow.

On 8 May 2018 at 05:57, Pradeep Sharma <pradeeps...@gmail.com> wrote:
check your models.py 

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Adam
Reply all
Reply to author
Forward
0 new messages