python - Django sort by Articles with most similar tags -


i have model articles , tags, using filter suggestions.

the article tags tags = article.tags.all() filter article.objects.filter(tags__in=tags)[:5] i'd add sort tags similar.

model article , tags

class article(models.model):     ...     tags = models.foreignkey(tag, blank=true, null=true)  class tag(models.model):     name = models.charfield(max_length=20, blank=true) 

i suggest use app django-taggit. taggablemanager has method similar_objects want.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -