[Django]-How to check if ManyToMany field is not empty?

30👍

✅

you should use the .exists method:

related_categories = example_category.related_categories
if related_categories.exists():
    # do something

Leave a comment