I have a view:
############################################
# list of topics in a forum
def topic_list(request, forum_id):
        topics =
Topic.objects.order_by('-topic_modification_date').filter(topic_forum=forum_id)
        for i in topics:
                pmax =  i.post_set.all().count()/10
                pmaxten =  i.post_set.all().count()%10
                if pmaxten != 0:
                        i.pagination_max = pmax+1
                else:
                        i.pagination_max = pmax
        if topics and topics[0]:
                forum_name = topics[0].topic_forum.forum_name
        else:
                forum_name = Forum.objects.get(id=forum_id)
                forum_name = forum_name.forum_name
        return render_to_response('myghtyboard/' + settings.MYGHTYBOARD_THEME
+ '/topics_list.html', {'topics': topics, 'forum': forum_id,  'perms':
list_perms(request), 'forum_name': forum_name})
###############################################
And in the template in the "for" loop I can access pagination_max but
when I change my view to a extended generic view to paginate topics I
can't acess this variable in the template:
##############################################
# list of topics in a forum
def topic_list(request, forum_id, pagination_id=1):
        from django.views.generic.list_detail import object_list
        topics =
Topic.objects.order_by('-topic_modification_date').filter(topic_forum=forum_id)
        for i in topics:
                pmax =  i.post_set.all().count()/5
                pmaxfive =  i.post_set.all().count()%5
                if pmaxfive != 0:
                        i.pagination_max = pmax+1
                else:
                        i.pagination_max = pmax
        if len(topics) > 0:
                forum_name = topics[0].topic_forum.forum_name
        else:
                forum_name = Forum.objects.get(id=forum_id)
                forum_name = forum_name.forum_name
        return object_list(request, topics, paginate_by = 5, page =
pagination_id, extra_context = {'forum':forum_id, 'perms':
list_perms(request), 'forum_name': forum_name}, template_name =
'myghtyboard/' + settings.MYGHTYBOARD_THEME + '/topics_list.html')
##############################################
"topics" have the correct data but it isn't available in the theme (the
rest is available as normal)

Is this a bug or I'm doing something wrong ?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to