I changed everything related to Model "class Citizen_voice" back to "class Poll" and now everything works with "Generic views" usage. Don't understand why my detail.html template will only accept the variable "poll.id"?
On Wednesday, July 3, 2013 12:39:18 PM UTC+2, Pepsodent Cola wrote: > > I just double checked. A month ago I followed the Django Polls tutorial > to the point and all of the above worked. > > But the second time I followed the Polls tutorial I used different Model > names such as *"class Citizen_voice(models.Model)"* instead of the > tutorials table name. > > class Poll(models.Model): > > > Will my underscore table naming convention cause problems with *"Generic > views"* usage? > > > > > > > > On Wednesday, July 3, 2013 12:37:50 AM UTC+2, Pepsodent Cola wrote: >> >> Hi, >> >> 1.) >> When following the Django 1.5 poll tutorial everything works ok. Until I >> try to implement the *"Generic views"* to use less code in the poll, >> then the poll app breaks. >> >> https://docs.djangoproject.com/en/1.5/intro/tutorial04/#use-generic-views-less-code-is-better >> >> >> 2.) >> When go to this link in my web browser, then I get the following error >> message. >> http://localhost:8000/polls/specifics/2/ >> >> Exception Value: >> >> Reverse for 'vote' with arguments '('',)' and keyword arguments '{}' not >> found. >> >> >> >> 3.) >> *Error during template rendering* >> /mysite/polls/templates/polls/detail.html, *error at line 6* >> >> http://pastebin.com/4HSt1VyS >> >> >> <h1>{{ poll.question }}</h1> >> >> {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% >> endif %} >> >> *<!-- poll.id = pk -->* >> *<form action="{% url 'polls:vote' pk %}" method="post">* >> {% csrf_token %} >> {% for choice in poll.choice_set.all %} >> <input type="radio" name="choice" id="choice{{ forloop.counter >> }}"value >> ="{{ choice.id }}" /> >> <label for="choice{{ forloop.counter }}">{{ choice.choice_text }}< >> /label><br /> >> {% endfor %} >> <input type="submit" value="Vote" /> >> </form> >> >> >> 4.) >> Which files do I need to edit when refactoring the old working code to >> the "Generic views" code? >> >> I have already edited *"polls/urls.py"*. >> https://docs.djangoproject.com/en/1.5/intro/tutorial04/#amend-urlconf >> >> And I have edited *"polls/views.py"* >> https://docs.djangoproject.com/en/1.5/intro/tutorial04/#amend-views >> >> And I tried to edit *"detail.html"* template file as described at point >> 3.) but I still get the same error message. >> *Error during template rendering* >> /mysite/polls/templates/polls/detail.html, *error at line 6* >> * >> * >> > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.

