Hi,
ListView and most other generic views are designed mostly to work with
single model.
There are few ways to tackle your problem depending on your needs.
to 3. lokak. 2019 klo 0.53 Yann Mbella kirjoitti:
> hi everyone,
> I got a problem in listing two models from a listview that is, a list
you probably may want to implement `get_context_data` method like:
def get_context_data(self):
context = super(BlogView, self).get_context_data()
context.update({
'authors':
Author.objects.filter(posts__isnull=False).distinct(),
'tags': Tag.objects.all()
Hi Yann,
You can try queryset union functionality:
class MultiFilterPlacesListView(ListAPIView):
"""Custom queryset api view. Does not implement pagination"""
pagination_class = None # Import custom pagination if you need the
pagination.
queryset = Places.objects.all()
slice
hi everyone,
I got a problem in listing two models from a listview that is, a list of
one model and another model together (eg Books and Authors)
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving
4 matches
Mail list logo