Hat-trick for getting categories related to an object group

1
2
3
4
5
## helpers.py
def get_categories(category_model, item_set):
    return [category for category in
            category_model.objects.all() if category in
            [item.category for item in item_set]]

More like this

  1. Quick-and-dirty decorator for static navigation context by pablo_PXL 2 years, 4 months ago
  2. self-related objects list with links by kumbry 5 years, 7 months ago
  3. CategoriesField by fongandrew 3 years, 10 months ago
  4. Lightweight querysets by sardarnl 1 day, 17 hours ago
  5. RelatedMixin for Details and Updates with Related Object Lists by christhekeele 1 year ago

Comments

(Forgotten your password?)