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
3
votes
2 answers

Adding many to many fields (M2M) manually in django?

I have a M2M field in my django model project. In my view I want to update a model instance with update() function. I know that for updating other ordinary fields we can pass a dictionary of the fields. But how can I pass M2M field to update()…
Arya Mz
  • 581
  • 3
  • 7
  • 20
2
votes
1 answer

Django annotate queryset by field from m2m through model

I have models BottleType and OrganisationBottleType. And i want to annotate BottleType queryset by fields 'is_accepted' and 'points' from OrganisationBottleType. OrganisationBottleType model: class OrganisationBottleType(models.Model): …
2
votes
0 answers

Directus - Permissions on M2M collection

I'm looking for a way to restrict an M2M collections according to the following rules: Customers can only delete, edit or view their own projects Professionals can only view projects assigned to them Here's my schema: And here are my…
Mario Rojas
  • 1,313
  • 1
  • 9
  • 15
2
votes
1 answer

Django 1.11 Direct assignment to the forward side of a many-to-many set is prohibited

I have one model UserSong which has two m2m fields with models Genre and Language class UserSong(models.Model): title = models.CharField(max_length=100) song_file = models.FileField(upload_to=user_song_directory_path,…
angrysumit
  • 221
  • 4
  • 16
2
votes
1 answer

django rest framework m2m update method

I have a couple of m2m fields in my serializer that I need to save on update. My create() method functions fine, however I get the following error with my code: Django :: 2.0.1 DRF :: 3.7.7 Direct assignment to the forward side of a many-to-many…
user1496093
  • 189
  • 3
  • 15
2
votes
1 answer

MPS run Model2Model transformation and TextGen from action

I am developing a plugin for Schedulability Analysis for mbeddr. In order to run an external tool, I want to transform the mbeddr-model to the external tool's model and use the Textgen aspect in order to create an input file for the external tool.…
Achim Stuy
  • 53
  • 8
2
votes
1 answer

Odoo on write() method check many2many relation

I have 2 classes: class my_request(models.Model): _name = 'my.request' _inherit = ['mail.thread', 'ir.needaction_mixin'] supply_ids = fields.Many2many(comodel_name='supply.conditions', …
fueggit
  • 859
  • 1
  • 22
  • 44
2
votes
0 answers

No Values in ManyToManyField

I have a UserProfile where the User chose a language. Users should have the possibility to chose more than one language so i tried to use a ManyToManyField like so: class Choices(models.Model): languages =…
Marla
  • 101
  • 1
  • 11
2
votes
1 answer

Python, Django - ValueError: "<...>" needs to have a value for field "..." before this many-to-many relationship can be used

Dear StackOverflow community. My question is related to the insertion of a new record to the table that contains a many2many fields field. I spent the entire day trying to resolve this problem by myself, read the django documentation and surfing…
Peter
  • 216
  • 1
  • 14
2
votes
1 answer

what is the difference between ETSI-M2M standard and OneM2M standard?

I am doing a project about the topic desinging and implementing an M2M Application using OM2M. When I found some documentation in the internet, I know that the OM2M is defined based on the ETSI-M2M and OneM2M Standard. These two standards make me a…
Ock
  • 1,262
  • 3
  • 18
  • 38
2
votes
1 answer

Django - How to build an intermediate m2m model that fits? / best practice

First of all I have to admit that I'm quite new to all this coding stuff but as I couldn't find a proper solution doing it myself and learning to code is probably the best way. Anyway, I'm trying to build an app to show different titleholders,…
2
votes
1 answer

How does a MQTT server send a message to a client saying that its not authorized to connect?

I have a MQTT client that sends a CONNECT packet the the MQTT broker with username and password. Now if the client is not authorized to connect, the broker is going to close the connection. How can the MQTT broker tell the client that the reason for…
user3266083
  • 103
  • 3
  • 12
2
votes
1 answer

What is the best way to save this relation in Django?

Let's imagine we are creating a site, where people can sell anything to other people. For example, we have two categories: Computers and Cars We have some filters for categories: Memory, CPU, Mileage, Color And we have values for these filters: 4GB,…
Kirill
  • 55
  • 5
2
votes
1 answer

Django query in detailview

I have a DetailVIew which returns a list of related objects (m2m through). It works just fine! But I need to search for objects' names and it is returning all objects instead of only the related ones. How can I approach…
Ronaldo Bahia
  • 576
  • 3
  • 24
2
votes
1 answer

Django: name of many to many items in the admin interface

I have a many to many field, which I'm displaying in the django admin panel. When I add multiple items, they all come up as "ASGGroup object" in the display selector. Instead, I want them to come up as whatever the ASGGroup.name field is set to. …
Adam Morris
  • 8,265
  • 12
  • 45
  • 68