Hi Lalit, On Mon, Nov 22, 2021 at 6:12 PM Lalit Suthar <[email protected]> wrote:
> we can go like > > ``` > > class Manager(...): > def get_context_data(self, **kwargs): > context = super() .... > context["open_tickets"] = Ticket.objects.filter(status="OPEN") > context["accepted_tickets"] = Ticket.objects.filter(status="ACCEPTED") > context["completed_tickets"] = Ticket.objects.filter(status="COMPLETED") > return context > ``` > > <https://groups.google.com/d/msgid/django-users/CAGp2JVHGLavBh8sZLqepP5QMcQYVdv1m0_AO_rKK0PAHun1NGA%40mail.gmail.com?utm_medium=email&utm_source=footer> That is certainly one value solution, though for any call there are potentially (ignoring cache) 3 db queries. To avoid that, an arg or kwarg could be passed to the view by implementing `get` and allowing for it in the associated path in urls.py. This is typically a better pattern and very similar to what Dango admin does when a filter is enabled. I would also avoid the word `Manager` in a CBV, since `Manager` has a special meaning in Django. Regards, David -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAE5VhgW3WcZASeOpfqo4_nxzPpZRJZrV-SWAKFByiDG56fxNGQ%40mail.gmail.com.

