Questions tagged [django-related-manager]

django-related-manager refers to the RelatedManager class that is used in Django to manage one-to-many or many-to-many related context

django-related-manager refers to the RelatedManager class that is used in Django to manage one-to-many or many-to-many related context.

129 questions
0
votes
0 answers

what could be the reason _set is not created on FK relation creation in Django?

I have the following data structure class A(models.Model): a number of fields here class AbstractParent(models.Model): some fields here class Meta: abstract = True class B(AbstractParent): a = ForeignKey(A,…
Daniel Kislyuk
  • 956
  • 10
  • 11
0
votes
0 answers

Django multiple table join on using ORM

I am trying to join multiple table using django ORM .i have tried several different way but no luck. from django.db import models from compositefk.fields import CompositeForeignKey, CompositeOneToOneField class Company(models.Model): code =…
0
votes
1 answer

Django: ManyToManyField related name not working

Im trying to output all the events that a member is one of the sponsors and speakers of that event. Using member.event_set.all works fine for members that were event speakers. But if I use member.msponsor_set.all for members that were event sponsors…
0
votes
1 answer

Querying RelatedManager objects

I have models such as class Model1(models.Model): f1 = models.DateField(null=True, blank=True) f2 = models.CharField(max_length=100,null=True, blank=True) f3 = models.CharField(max_length=100,null=True, blank=True) class…
0
votes
1 answer

Django ManyToMany related manager with no objects returns True

Django 1.9, Python 3.6, postgres DB There exists Calendar and CalendarOwner, where the many-to-many relationship is defined in Calendar. class Calendar(models.Model): ... calendar_owners = models.ManyToManyField( …
camelBack
  • 748
  • 2
  • 11
  • 30
0
votes
1 answer

Django ForeignKey in same table about same attribute in different table

I have one model in my project. class users(models.Model): match_user = models.ForeignKey(User,on_delete=models.CASCADE) matched_user = models.CharField(max_length=25) Imagine that: match_user is 'Mete' and matched_user is 'Gizem'. Also…
0
votes
2 answers

Django Rest Framework: Just get certain values of a ManyToMany relationship

I'm using Django Rest Framework to write my API. I want to write different values than the the id (specifically the uuid) into my serializer. Let me give you the basic setup first. I have a model called House which has amongst other values a pk and…
0
votes
1 answer

Django - nested relation query with the ORM

Because I need to avoid a recursive import and work with a Group object as my starting point for my query (which is why I can't import Action objects directly.) The relationship is Group -> Component -> ComponentVersion -> Action For instance,…
mburke05
  • 1,371
  • 2
  • 25
  • 38
0
votes
0 answers

Model Creation calls its related model save method?

Having these kind of model definitions and a relationship between the two: class Car(models.Model): description = models.CharField(max_length=35) def save(self, **kwargs): invalidate_cache() super().save(**kwargs) def…
Leonardo
  • 4,046
  • 5
  • 44
  • 85
0
votes
0 answers

Bulk create in related objects

I have 2 models in my app - In models/parent.py I have - from django.db import models class Parent(models.Model): class Meta: db_table = "parent_table" start_date = models.DateField() end_date =…
0
votes
0 answers

How to implement a form to add a video using M2M model with through_fields?

I have this model from this question: class Category(models.Model): category = models.CharField(max_length=50) def __str__(self): return self.category class Tag(models.Model): tag = models.CharField(max_length=50) def…
Jeflopo
  • 2,192
  • 4
  • 34
  • 46
0
votes
0 answers

Prefetch Related not working as expected

I'm developing an API with Django 1.11.11 and python 3.6.4. I have the following model: class Subsection(models.Model): genres = models.ManyToManyField(Genre, blank=True, default=None) tags = models.ManyToManyField(Tag, blank=True,…
FVod
  • 2,245
  • 5
  • 25
  • 52
0
votes
2 answers

how to check if a model is in a models foriegn key set? Django, django rest framework

I have a room model which has a many to one relation with a venue. A venue can have many rooms. I am trying to set up my http methods in my rest framework so that way when I add permissions things work well. So if say someone wants to delete a…
user9487981
0
votes
1 answer

using foreign key set in django models django rest framework

I am having an interesting problem. I am using the ForeignKey call in the relations mananger. I.e. if I want all the objects from a related model known as hamsters the call would be hamsters_set now here is a working model attached to a serializer…
user9487981
0
votes
2 answers

how to: creating a view and serializer for adding, editing, and deleting objects with foreign relationships django rest framework

I am having a very hard time connecting all the documentation on django and django rest framework on how to create a view and serializer that allows for a foreign key. edit: I might have an answer here:…
1 2 3
8 9