Answer the question
In order to leave comments, you need to log in
How to sort chain?
How to sort chain by date whose fields have different names in models?
guides = Guide.objects.filter(author=user).order_by('-publish')[:10]
articles = Article.objects.filter(author=user).order_by('-publish')[:10]
memes = Meme.objects.filter(author=user).order_by('-publish')[:10]
comments = XtdComment.objects.filter(user=user).order_by('-submit_date')[:10]
result_list = sorted(chain(guides, articles, memes, comments), key=lambda instance: instance.publish) # <------- ??
Answer the question
In order to leave comments, you need to log in
Make a property on model objects that will return the values of different fields. File an annotation (qs.annotate()) that will return different fields under the same name.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question