1.)
Well I took the working *"class Poll"* version and changed much into *"class 
Polly_bird"* instead to see if the underscore business was indeed causing 
me this problem.


2.)
So I deleted the database.


3.)
And edited this file *"/mysite/polls/urls.py"*.

urlpatterns = patterns('',
...
...
    # ex: /polls/5/
    url(r'^(?P<pk>\d+)/$', views.DetailView.as_view(), name='detail'),

    # ex: /polls/5/vote/
    url(r'^(?P<polly_bird_id>\d+)/vote/$', views.vote, name='vote'),
)



4.)
And edited this file *"/mysite/polls/admin.py"*.

from polls.models import Polly_bird, Choice
...
...
class Polly_birdAdmin(admin.ModelAdmin):
...
...
admin.site.register(Polly_bird, Polly_birdAdmin)



5.)
And edited this file *"/mysite/polls/models.py"*.

class Polly_bird(models.Model):
...
...
class Choice(models.Model):
    PollChoice = models.ForeignKey(Polly_bird)
...
...



6.)
And edited this file *"/mysite/polls/views.py"*.

from polls.models import Polly_bird, Choice

class IndexView(generic.ListView):
...
...
        return Polly_bird.objects.order_by('-pub_date')[:5]

class DetailView(generic.DetailView):
    model = Polly_bird
...
...

def vote(request, polly_bird_id):
    p = get_object_or_404(Polly_bird, pk=polly_bird_id)
...
...

class ResultsView(generic.DetailView):
    model = Polly_bird
...
...



7.)
Then I ran "python manage.py syncdb" to create the database tables from 
scratch.  After that I restarted the runserver.


8.)
Then I got the original error again, what line of code have I missed and in 
which files?
Or why doesn't Django like it when I use underscore table naming convention?

http://localhost:8000/polls/1/

Exception Value: 

Reverse for 'vote' with arguments '('',)' and keyword arguments '{}' not found.


Error during template rendering
/mysite/polls/templates/polls/*detail.html*, error at line *5*

...
...

5    <form action="{% url 'polls:vote' poll.id %}" method="post">

...
...












On Wednesday, July 3, 2013 3:51:50 PM UTC+2, ke1g wrote:
>
> Are you sure that you changed *everything*, including the database tables?
>
>
> On Wed, Jul 3, 2013 at 9:21 AM, Pepsodent Cola 
> <[email protected]<javascript:>
> > wrote:
>
>> 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<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/<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<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<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] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

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


Reply via email to