manytomanyfield

Django Rest Framework: Count Number of Objects with multiple ManyToManyField values

Django Rest Framework: Count Number of Objects with multiple ManyToManyField values Question: In the example below, I have two models with a ManyToMany relation and I’m trying to count the number of posts related to the tags. There are 3 tags: Sports, Films, Health There are 3 posts: 1 for Sports, 1 for Films and …

Total answers: 4

lack of foreign key in admin model?

lack of foreign key in admin model? Question: I get the following error when trying to update my database: class ‘artdb.admin.RoleInline’: (admin.E202) ‘artdb.Role’ has no ForeignKey to ‘artdb.Person’ I want ot have a many to many relation between Person and Role model.py (not showing all classes): class Person(models.Model): mail=models.EmailField() firstName=models.CharField(max_length=200) lastName=models.CharField(max_length=200) phoneNumber=PhoneNumberField() streetAdress=models.CharField(max_length=200) zipcode=models.CharField(max_length=200) city=models.CharField(max_length=200,default="Göteborg") …

Total answers: 2

Show a ManyToManyField as Checkboxes in Django Admin

Show a ManyToManyField as Checkboxes in Django Admin Question: Is there a simple way to show a ManyToManyField as Checkboxes in Django Admin? Thanks in advance! Asked By: eos87 || Source Answers: From this answer it seems like it is possible to use ModelAdmin.formfield_overrides to override the ManyToManyField to use CheckBoxSelectMultiple: from django.db import models …

Total answers: 4