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
0 answers

django-parler - M2M Relationship Issue with Admin M2M Field (Circular Dependency?)

we're facing an issue with the use of M2M relationships - It seems we have a circular dependency issue? We need to make a M2M relationship to a TranslatableModel field (which is M2M under the hood), exposed in the Admin (we have a multi-select…
SiNGH
  • 11
  • 1
1
vote
1 answer

Add ManyToMany field on save

I have a model with a ManyToMany field, and everytime I create an object I need to search the database for more objects with the same phone or email created previously. Right now, I am using a post_save signal to do this, but I wanted to know if…
Stargazer
  • 1,442
  • 12
  • 19
1
vote
1 answer

Django ManyToMany chained queryset not giving ANDed result

This is leaving me baffled for a while. I've a ManyToMany Relationship established through a table as shown: class Coupon(TimeStampedUUIDModel): venue = models.ManyToManyField('venues.Venue', through='VenueCouponConfig',…
Sanyam Khurana
  • 1,336
  • 1
  • 14
  • 27
1
vote
0 answers

How to get values of m2m fields before saving in database?

I want to get values of m2m fields when I changi this fields in my model. I tried to use m2m_changed signal, but I get None values in action, pk_set,instance. What am I doing wrong? @receiver(m2m_changed, sender=UserProfile) def…
1
vote
1 answer

Django ManyToManyField initializes with all objects by default

I have 2 classes, Player and Game. Players can own multiple games, so we are using a m2m relation inside the Player model: class Player(models.Model): store_user = models.OneToOnefield(User, unique=True, on_delete=models.CASCADE) games =…
Jussi Hietanen
  • 181
  • 1
  • 1
  • 12
1
vote
1 answer

Getting all objects with equal M2M fields

I am looking for a way to filter for all objects of the same type that have the same querysets for a M2M field. class Comment(models.Model): user = models.ForeignKey(User, related_name='comment_user') content =…
JayBee
  • 540
  • 1
  • 5
  • 22
1
vote
2 answers

Stm32f4 dma m2m

I'm using STM32F407VG Discovery Board and I've issue with DMA memory to memory transfer. I want to copy 32 bytes of data from one place in memory to other using DMA by writing copy_dma() function. In while loop i'm checking Transfer Complete flag…
1
vote
1 answer

What is the difference between "AT+QIACT" and "AT+CGDCONT"

I have Quectel-EC21 LTE module but have a little problem to initialize. I have really confused about "AT+QIACT" and "AT+CGDCONT" commands. Both actived PDP context but dont know what is the difference between. I will have APN name, username and…
TR53
  • 11
  • 1
  • 3
1
vote
1 answer

I'm thinking about running a COAP system backwards, is this a terrible idea?

I'm building a very simple sensor that needs to upload data to a cloud server for storage and I'm looking for a simple protocol to use. I'm running on a PIC chip so I'm pretty seriously constrained on memory so it really will have to be simple. I've…
TheGribble
  • 25
  • 7
1
vote
2 answers

Filter many-to-many relationship by user and show in template Django

I'm stucked with a problem. I'm developing e-Learning application and have this model (simplified for better understanding): class Course(models.Model): name = models.CharField(max_length=100) description = models.CharField(max_length=255) …
Gui
  • 763
  • 1
  • 7
  • 20
1
vote
1 answer

Django many2many is a subset of another set

Given a model with an m2m field, let's say Article has multiple Authors. What is the most efficient way to get all the articles in which the set of their authors is a subset of another set? class Article(models.Model): authors =…
Jiyda Moussa
  • 925
  • 2
  • 9
  • 26
1
vote
2 answers

Check if User is in Many2Many field

I have the following model with a m2m field where logged in Users can show interest in a publication: models.py from django.db import models class Publication: title = models.CharField(max_lenth=512) users_interested =…
fuser60596
  • 1,087
  • 1
  • 12
  • 26
1
vote
1 answer

relationship to a Django many to many relationship?

I'm relatively new to Django and OO, so I may be missing something obvious, but I can't wrap my head around how to model the following: I have locations. I have games. Each location can have as many games as it needs, and games can be in multiple…
Zoom
  • 13
  • 2
1
vote
2 answers

Django Model self referencing M2M field

I'm trying to get a Django model to automatically construct a typical __str__(self) value for itself (in the model definition), but based on 3 ManyToMany Fields. Unlike when using basic field types (as in the first two models), this doesn't appear…
FunkyOne
  • 51
  • 1
  • 5
1
vote
1 answer

Django REST framework many to many serializer

I got models: class Car: name = models.CharField(max_length=50, blank=True, default='') class Wheel: name = models.CharField(max_length=50, blank=True, default='') cars = models.ManyToManyField(Car) and serializers: class…
Danila Kulakov
  • 1,082
  • 1
  • 12
  • 20