Questions tagged [m2m]

A type of relationship between entities of types A and B which associates a list of entities of type B to an entity of type A and vice versa. Types A and B may be the same type

A type of relationship between entities of types A and B which associates a list of entities of type B to an entity of type A and vice versa. Types A and B may be the same type.

See also:

271 questions
4
votes
0 answers

OMA - DM simulator and client code

I understand that the OMA - DM client is not released as standalone library, but how to extract client code from the simulator source code?
Manas Pratim Chamuah
  • 1,527
  • 2
  • 15
  • 33
4
votes
1 answer

Edit the opposite side of a many to many relationship with django generic form

I have two models: class Actor(models.Model): name = models.CharField(max_length=30, unique = True) event = models.ManyToManyField(Event, blank=True, null=True) class Event(models.Model): name = models.CharField(max_length=30,…
Ed.
  • 4,439
  • 10
  • 60
  • 78
4
votes
1 answer

Python Django: Use dumpdata for single model with m2m field and mySql

I have a model Lecture with some m2m fields in it, which I would like to dump using dumpdata. But whenever I call python manage.py dumpdata cms.lecture I get the following error CommandError: Unable to serialize database: 'NoneType' object has no…
Magda
  • 1,218
  • 3
  • 14
  • 31
3
votes
2 answers

django remove m2m instance when there are no more relations

In case we had the model: class Publication(models.Model): title = models.CharField(max_length=30) class Article(models.Model): publications = models.ManyToManyField(Publication) According to:…
lpares12
  • 3,504
  • 4
  • 24
  • 45
3
votes
2 answers

"Incorrect type. Expected pk value, received list." Error DRF React

Error when attempting post request Many to Many Relation Question is when I put list in request It shows an Error: "Incorrect type. Expected pk value, received list." .But it is m2m field so how can i View class…
3
votes
2 answers

django-reversion revert ManyToMany fields outside admin

I am using django-reversion in my project. And it works good except one thing: I can't get previous versions of ManyToMany fields. But in django admin it is works, not in my code. To get previous version I use following code: vprod =…
Eugene Nagorny
  • 1,626
  • 3
  • 18
  • 32
3
votes
1 answer

django pre_save validation on m2m (many to many) fields

Apologies if this has been answered before but have been searching for hours. I am trying to do validation on a django rest model with a m2m field. I have a model that has roles assigned to it. I have some logic if the roles overlap with exisiting…
Bhavesh
  • 51
  • 3
3
votes
1 answer

IntegrityError: (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (..))

when deleting users with schedule_files I got this: IntegrityError at /admin/auth/user/166/delete/ (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (vacation.vacations_schedulefile, CONSTRAINT…
Stanislav
  • 67
  • 2
  • 8
3
votes
2 answers

Django Rest Framework - M2M via through

Im having trouble with retrieving all fields I need from serializer. Scenario: I have 2 tables: Item & Warehouse. Those tables are connected via M2M relationship via through table called InventoryStatus. What I need is to get Item info with nested…
Jakub Mana
  • 81
  • 1
  • 9
3
votes
3 answers

Django filter exact m2m objects

Let's say I have a team model, and a team has members. So class Team(models.Model): team_member = models.ManyToManyField('Employee') class Employee(models.Model): .... Lets say I have a list of employee ids like team_members = [1001, 1003,…
Rob L
  • 3,634
  • 2
  • 19
  • 38
3
votes
1 answer

Using an UML profile in QVTo transformation?

I have defined an UML profile using the Papyrus tool and saved the file as "my_profile.di". How do I use this profile inside a QVTo transformation? Is it possible to do something like this (I'm not sure how the path to the file should be specified…
Incinerator
  • 2,589
  • 3
  • 23
  • 30
3
votes
1 answer

Django 1.8: When items are related via two separate relationships, how can I specify which relationship to use?

I have User (django's default model) and Interest. They are related to eachother through two many-to-many through models, so track additional data on the relationships. One model, Selected, tracks which interests a user wants to be associated…
StringsOnFire
  • 2,726
  • 5
  • 28
  • 50
3
votes
2 answers

Django 'ModelForm' object has no attribute 'cleaned_data' for M2M through

Hi everyone I'm facing issues with create a M2M through. With the code below, I get the message: 'SendCandForm' object has no attribute 'cleaned_data' If I change #forms.py cojobs=Company.objects.select_related('job').values_list('job__title',…
Ronaldo Bahia
  • 576
  • 3
  • 24
3
votes
2 answers

Django: accessing ManyToManyField objects after the save

This is baffling me... When I save my model, the book objects are unchanged. But if I open the invoice and save it again, the changes are made. What am I doing wrong? class Invoice(models.Model): ... books =…
tufelkinder
  • 1,176
  • 1
  • 15
  • 37
3
votes
1 answer

Prepopulating Django M2M field based on another M2M

I am trying to prepopulate many2many field on saving the model through another many2many field in the same model: class CommissionReport(models.Model): ... law = models.ManyToManyField('Law', blank=True, null=True) categories =…
Iliyan Tatarov
  • 504
  • 4
  • 9
1 2
3
18 19