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
1
vote
1 answer

Django, how to have an array in model without M2M?

I want my model to have an array of other model's instances. Let me explain. I have a Company model which has a localizations field which is supposed to be a set/array of addresses. Since one address can only be for one Company, M2M relationship…
Karol
  • 600
  • 7
  • 18
1
vote
1 answer

Many-to-Many relationship in Django

I have the following 3 models: class Platform(models.Model): title = models.CharField(max_length=100, unique=True) class Profile(models.Model): title = models.CharField(max_length=110, unique=True) platform =…
1
vote
1 answer

Graph IRI in a SPARQL Query and SPARQL UPDATE operation in oneM2M IoT Standard?

In oneM2M, the can be updated with SPARQL UPDATE operation with INSERT/DELETE and a Semantic Query (SELECT, CONSTRUCT, ASK, DESCRIBE) can be targeted towards a resource to derive semantic information. For Update of…
Siddharth Trikha
  • 2,648
  • 8
  • 57
  • 101
1
vote
1 answer

How can i query with ManyToManyField?

If i know company_id, how can i call a query list department, each department have list user and each user has username and staff_id? Example models and output below class User(models.Model): …
1
vote
1 answer

Django form to save m2m additional fields (using custom through/intermediary model)

I have a "Parent" model, which contains multiple "Child" models and the relationship between Parent and Child holds the order of the children. Thus, I need a custom intermediary model. models.py: class Parent(models.Model): name =…
Anubis
  • 11
  • 1
1
vote
2 answers

How to calculate count in Django through two m2m levels?

I have 3 models like: class Customer(models.Model): hobby_groups=models.ManyToManyField( 'HobbyGroup', blank=True, related_name='group_customers', ) class HobbyGroup(models.Model): hobbies =…
marcustas
  • 46
  • 3
1
vote
0 answers

Django Forms - Get object if exist - Unique Field - M2M

I'm still a junior with django. Please explain in detail :D I'm developing a system to manage Full Days for restaurants. A full day can have many guests, and a guest can have many full days. M2M Relationship. My model classes: class…
1
vote
1 answer

UPDATE of nested attributes in a resource

There are many complex resources in oneM2M with nested attributes e.g. subscription, group etc. If an UPDATE request is sent to update a nested attribute e.g. eventNotificationCriteria>missingData>number of subscription resource then all other…
Poornima
  • 77
  • 4
1
vote
1 answer

Relationship to "jump" through M2M relationships in SqlAlchemy (User -> Role -> Permission)

I am trying to model a very typical permission structure where a User model (the human user of my website) can be assigned to some Roles, and each of those Roles has some Permissions. It would be really helpful if I could get a relationship from…
Savir
  • 17,568
  • 15
  • 82
  • 136
1
vote
1 answer

Django admin select m2m items based on their tags (item's m2m field)

Consider following models: class Library(models.Model): name = models.CharField(max_length=64) books = models.ManyToManyField(Book) class Book(models.Model): name = models.CharField(max_length=64) tags =…
Jura Brazdil
  • 970
  • 7
  • 15
1
vote
1 answer

Django: How to access m2m relationship and use it to create a filepath. Or: how to save a model's relationships first and then the rest

So, assume I have the following (simplified) Django model: class Document(models.Model): def get_file_path(self, filename): extension = filename.split('.')[-1] product_string = ', '.join(p.__str__() for p in…
Landcross
  • 472
  • 7
  • 16
1
vote
2 answers

m2m django implementation after following a tutorial

Scenario: I have some boxes (containers) I have some objects (samples) a sample can be split over many boxes, a box can contain many samples. I want to be able to assign a sample to a box and remove a sample from a box. I followed these tutorials…
Spatial Digger
  • 1,883
  • 1
  • 19
  • 37
1
vote
0 answers

How to implement m2m_changed?

Basically, my question is how do I implement the m2m_changed so that when I am creating, updating, or deleting an instance of ClassSubjectGrade, the intermediate table between ClassSubjectGrade and Student is also updated. Example: Adding more…
mike26
  • 71
  • 3
  • 9
1
vote
3 answers

Database structure: Would this structure work with this m:m?

Here is my issue: (Using MySQL) I have 2 entities called 'shops' and 'clients'. I also have a M:M table between 'clients' and 'shops' called 'clients_shops' (CakePHP naming convention). The reason I am doing it this way is that this is a SaaS…
1
vote
2 answers

Adding M2M on post_save

I have an object that has a m2m relation, and I would like to populate it after saving. The problem is that the signal is triggered, but the command add doesn't work. I did try the same steps using python shell, and it worked fine. class…
Stargazer
  • 1,442
  • 12
  • 19