Projet

Général

Profil

« Précédent | Suivant » 

Révision a2aba77e

Ajouté par Serghei Mihai il y a environ 7 ans

add pagination for announces (#13878)

Voir les différences:

corbo/views.py
129 129
edit_category = CategoryEditView.as_view()
130 130

  
131 131

  
132
class CategoryView(DetailView):
133
    model = models.Category
132
class CategoryView(ListView):
133
    model = models.Announce
134
    paginate_by = settings.ANNOUNCES_PER_PAGE
135

  
136
    def get_queryset(self):
137
        qs = super(CategoryView, self).get_queryset()
138
        return qs.filter(category__slug=self.kwargs['slug'])
134 139

  
135 140
    def get_context_data(self, **kwargs):
136 141
        context = super(CategoryView, self).get_context_data(**kwargs)
137
        context['announces'] = self.object.announce_set.all().order_by(
138
                '-publication_time', '-ctime')
142
        context['category'] = models.Category.objects.get(slug=self.kwargs['slug'])
139 143
        return context
140 144

  
141 145

  

Formats disponibles : Unified diff