Hi Leo,

I changed everything that you suggested and things are working perfect. 
 Thank you!!! :)

*[Solved]*


On Tuesday, October 15, 2013 3:45:36 AM UTC+2, Pepsodent Cola wrote:
>
> Hi,
>
> I got some help by somebody on #django IRC.  They gave me this code 
> snippet to fix my problem.  But I'm having problems incorporating that code 
> into my Class file because Template file says "No list is available" when I 
> try to access the list variable.  What am I doing wrong?
>
> # Filter 8
>     def altword_list(self, request, word_id):
>         #object_list = 
> AltWord.objects.filter(word__pk=word_id).order_by('-votes')
>         object_list = 
> Altword.objects.filter(word__pk=word_id).order_by('-votes')
>
>         return render(request, 'navi_polls/altword_list.html', {
>             'poll_list': object_list,
>         })
>
>
>
> *Views*
>
> #_______________________________________________________________________________
>
> class AltwordlistView(generic.DetailView):
>     #model = Word
>     model = Altword
>     template_name = 'navi_polls/altword_list.html'
>     context_object_name = 'poll'
>
>     def get_queryset(self):
> # Filter 5
>         #return Word.objects.filter(direct_transl_word='')
>
>
>     def get_context_data(self, **kwargs):
>         context = super(AltwordlistView, self).get_context_data(**kwargs)
> # Filter 4b
>         filter_4b = 
> Altword.objects.filter(rosword__direct_transl_word='').order_by('-votes')
> # Filter 7
>         filter_7 = Altword.objects.vote_order()
> # Filter 8b
> #        filter_8b = 
> Altword.objects.filter(word__pk=word_id).order_by('-votes')
>
>
>         context.update({
>             "filter_4b": filter_4b,
>             "filter_7": filter_7
>  #           "filter_8b": filter_8b
>         })
>         return context
>
>
> # Filter 8
>     def altword_list(self, request, word_id):
>         #object_list = 
> AltWord.objects.filter(word__pk=word_id).order_by('-votes')
>         object_list = 
> Altword.objects.filter(word__pk=word_id).order_by('-votes')
>
>         return render(request, 'navi_polls/altword_list.html', {
>             'poll_list': object_list,
>         })
>
> #_______________________________________________________________________________
> *
> *
>
>
> *Template*
>
> #_______________________________________________________________________________
>
> <!-- Filter 8 -->
> {% if poll_list %}
>     <ul>
>     {% for row in poll_list %}
>         <li>( id:{{ row.id }} ) - {{ row.rosword }}</li>
>     {% endfor %}
>     </ul>
> {% else %}
>     <p>No list is available.</p>
> {% endif %}
>
>
> <!-- poll.altword_set.all.order_by('-votes') -->
> <!-- for choice in poll.altword_set.all -->
> <!-- for choice in poll %} -->
>
> <!-- for choice in poll_list -->
> <!-- for choice in poll_list.altword_rosword.all -->
> {% for choice in poll_list %}
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/3ea6c541-5b43-4838-adc2-fbdd80953cc9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to