V
V
vfvnvsyevsky2015-03-03 21:07:52
Django
vfvnvsyevsky, 2015-03-03 21:07:52

How to implement ManyToManyField queries in Django?

There is a table:

class Category(models.Model):
  category_name = models.CharField(max_length = 200)	
  category_nested = models.ManyToManyField('self', symmetrical=False)

How to pull out only those category_names that have no links to other rows in the table and only those category_names that have links?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey K, 2015-03-04
@mututunus

Category.objects.filter(category_nested=[])
Category.objects.exclude(category_nested=[])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question