0

i create a models in django , with ManyToMany relation , and i have a problem :

 class KeyCat(models.Model):
    category = models.CharField(max_length=255)

    def __str__(self):
        return self.category


class Keyword(models.Model):
    category = models.ManyToManyField(KeyCat)

that create two table : "keycat", "keyword" and "keyword_category" i want to delete from "keywords_keyword_category" a row where id=1

John club
  • 19
  • 3
  • So why you are not showing us keyword_category model? – alv2017 Mar 21 '21 at 21:36
  • I would also say that you are missing keyword field in keywords, and it is not clear what do you mean by keywords_keyword_category" a row where id=1. – alv2017 Mar 21 '21 at 21:44
  • If you want to remove a Category object related with a Keyword object you just need to call `remove`. See the [docs](https://docs.djangoproject.com/en/3.1/topics/db/examples/many_to_many/) – 2293980990 Mar 22 '21 at 04:13
  • Does this answer your question? [How to update manytomany field in Django?](https://stackoverflow.com/questions/1194737/how-to-update-manytomany-field-in-django) – 2293980990 Mar 22 '21 at 04:14

0 Answers0