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

What would be the most djangoish way to run through relations until last child?

I'm struggling on finding an efficient way to go through Django m2m relations. My use is case : I receive a string from a form and update the status of an element with this string. If this element has children, I update their status with the same…
May.D
  • 1,832
  • 1
  • 18
  • 34
0
votes
1 answer

Django ManyToMany intermediary model, move relationship

So, after reading the documentation regarding intermediary model's, it seems that there's no built-in way of changing one side of a relationship without clearing all relationships with that side. But how can I do this anyway? I was thinking that I…
dcolumbus
  • 9,596
  • 26
  • 100
  • 165
0
votes
0 answers

tastypie save_m2m, TagRelatedManager evaluates to False

Actually, I'm trying to save a tastypie model resource which contains a TagField from django-tagulous Here are my model, and resources: # models.py class SimpleModel(models.Model): topics = tagulous.models.TagField() title =…
slackmart
  • 4,754
  • 3
  • 25
  • 39
0
votes
1 answer

How to select entire intermediate table in Django

In my database I have citations between objects as a ManyToMany field. Basically, every object can cite any other object. In Postgres, this has created an intermediate table. The table has about 12 million rows, each looks roughly like: id |…
mlissner
  • 17,359
  • 18
  • 106
  • 169
0
votes
2 answers

Djano many to many relation with User

class Relationship(models.Model): from_user = models.ForeignKey(User, related_name='from_user') to_user = models.ForeignKey(User, related_name='to_user') status = models.CharField(max_length=255, choices=RELATIONSHIP_STATUSES) field =…
0
votes
1 answer

How do I display a related object set in django?

I know the question seems simple to answer, and that the answer would be in the API ref somewhere, but I'm a bit new to django and have poured through the API for days trying to get this done. Any help would be highly appreciated! I'm creating a…
0
votes
2 answers

Django : Defining OneToMany Relationship

I am confused of defining OneToMany relation in django which is not in Django. ManyToOne field can be done using ForeignKey but i dnt have idea to define for OneToMany. here is my problem, I want to add Users as a list to a model. Class…
Wickkiey
  • 4,446
  • 2
  • 39
  • 46
0
votes
1 answer

Django One(Many)-To-Many Relation in reusable app

I have a model named Exam. each Exam has a set of users called participants. The only way I found to keep such set in Django is to add a field in User model. But I'd prefer to write this model to be as independent as possible so if later I want to…
Matrix
  • 98
  • 1
  • 11
0
votes
1 answer

Django updates that span relationships

I would like to run an update query that spans several realtionships. Is this possible with django? This is what I have tried: from django.db.models import F Transaction.objects.filter(pk__lt=10).update( …
Chase Roberts
  • 9,082
  • 13
  • 73
  • 131
0
votes
2 answers

Django Returns `Cannot assign "1": "Likes.user_id" must be a "Users" instance.`

I have these models and I have burnt all the night trying to figure how I could save to Likes table but it won't just work. class Users(models.Model): email = models.EmailField() name = models.CharField(max_length=60) class…
Yax
  • 2,127
  • 5
  • 27
  • 53
0
votes
0 answers

Use django-reviews package with an app which uses customized user model

I am working on a django App where I am using a custom user models for AUTH_USER_MODEL i.e AUTH_USER_MODEL = 'account.User'I extended the AbstractBaseUser class to create my model that is like class User(AbstractBaseUser): is_provider =…
0
votes
1 answer

Set django related model set and delete models no longer in set

In the Django documentation, it mentions that when you directly specify the new related set, any models no longer in the set are simply disassociated instead of deleted. In other words, if you have a situation like this: #author.books contains…
Leah Sapan
  • 3,621
  • 7
  • 33
  • 57
0
votes
1 answer

How to get related set models without hit database in Django

Here you'll always get two separate db calls, and adding select_related() anywhere won't help at all. One extra db call isn't that significant.
    {% for obj in myobjects %}
  • {{ myobj.name }}
    • {% for relobj in…
0
votes
2 answers

Selecting data from few relational tables based on few conditions in Django

I'm using Django 1.6 with Python 2.7 and I have few related models: # keys/models.py class Key(models.Model): user = models.ForeignKey('auth.User') is_valid = models.BooleanField() # entities/models.py class Entity(models.Model): user =…
errata
  • 5,695
  • 10
  • 54
  • 99
0
votes
0 answers

Reverse relation (ForeignKey) in Django ORM with unique combination

Hi I was just wondering if this is feasible through Django ORM: Please ignore model names etc, they are not real class Image(models.Model): ... item = models.ForeignKey(Bag, related_name="images") flag_frontpage_image =…
petkostas
  • 7,250
  • 3
  • 26
  • 29
1 2 3
8
9