These are chat archives for django/django

11th
Feb 2016
FelipeBHZ
@felipebhz
Feb 11 2016 14:10
Is there anybody online?
Omar Quimbaya
@WritingPanda
Feb 11 2016 14:50
@ionescu77 we can work remotely for the right candidate. If you're interested in working with a security company, please let me know.
Răzvan Ionescu
@ionescu77
Feb 11 2016 14:52
M
Cannot have private chat in gitter iOS app. Ok thank you. I will meditate during the flight and take this outside Django chat before people start cursing me :smile:
agusmakmun
@agusmakmun
Feb 11 2016 18:32

Somebody know how to limit posts with multiple tags.
example like this picture:
duplicate

This script is worked for 1 tag only, but if i try with 2 or more tags, have an duplicate posts.

def get_context_data(self, **kwargs):
    context_data = super(MySuper, self).get_context_data(**kwargs)
    related_entries = models.Entry.objects.filter(
        tags__in=list(self.object.tags.all())
        ).exclude(id=self.object.id)
    context_data['related_entries'] = related_entries[:5]
    return context_data

Any idea how to solved it? Thanks so much before..

agusmakmun
@agusmakmun
Feb 11 2016 18:53
Solved: using .distinct(), http://stackoverflow.com/a/5879542/3445802