Z
Z
zyusifov112022-04-07 16:13:06
Django
zyusifov11, 2022-04-07 16:13:06

Why does Django many-to-many delete() delete from a dependent model?

class BrandName(models.Model):
    industry = models.ManyToManyField('brands.Industry')

BrandName_object.industry.all().delete()

why does this function also remove the object from "brands.industry"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2022-04-07
@bacon

Because delete is deleting an object, not a link, why did you immediately come here, and didn’t go and read the docs on how to work with a link https://docs.djangoproject.com/en/4.0/ref/models/r.. .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question