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

Exclude objects in list in Django

I'm trying to make a new list of unused/unselected objects, so that I can show in the template what is used, and what is not used. My model: class Benefit(models.Model): name = models.CharField(max_length=200) class Profile(models.Model): …
Tomas Jacobsen
  • 2,368
  • 6
  • 37
  • 81
0
votes
1 answer

JSON for Foreign Key relationships

Let's say I have an example like the doc's: class Reporter(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) email = models.EmailField() def __unicode__(self): return…
user2476581
  • 135
  • 2
  • 9
0
votes
1 answer

List of publishers for an author

This works, but is there a Django idiom that does it better? my_books = Book.objects.filter(author__name=='me') my_publishers = Publisher.objects.filter(pk__in=[b.publisher.id for b in my_books]) models = round_up_the_usual_suspects() class…
neil.millikin
  • 1,077
  • 1
  • 10
  • 15
0
votes
2 answers

How to use RelatedManager add() method in save()

Banging head against the wall again. I'm trying to add tags using other known fields # models.py class MyModel(models.Model): ... tags = models.ManyToManyField(Tag, blank=True) field_m2m = models.ManyToManyField('M2mModel', blank=True) …
gwaramadze
  • 4,523
  • 5
  • 30
  • 42
0
votes
1 answer

django - how to get searched object in template thru relatedmanager

I am trying to write a search logic. but i am stuck here. I have Location Model and Rate Model. Each Location can have multiple rates. these are classes class Location(models.Model): name = models.TextField() price =…
doniyor
  • 36,596
  • 57
  • 175
  • 260
0
votes
1 answer

django related manager - get specific data

I am trying to get rate of the user who has written the comment. this is the scenario: I hold the comment about Something in my hand, I hold the user in my hand who wrote this comment Something. Now I need to know the rate which is given by the…
doniyor
  • 36,596
  • 57
  • 175
  • 260
0
votes
2 answers

How to do validation on django's ManyRelatedManager?

I would like to change the behavior, maybe overwriting, when I add an instance to a M2M relation, so that I could do something like this: try: my_instance.one_field_set.add( another_instance ) except ValidationError: # do something Is that…
zVictor
  • 3,610
  • 3
  • 41
  • 56
-1
votes
1 answer

How to 'order_by' model objects in Django using a field several levels of relationship apart

I have multiple models for an app that will contain option to generate forms for various companies. I am using mySQL. Also, I am a Noob :( FSForm is the master form. Whenever it is generated, it gets its 'fskey' from the 'Company' object (some logic…
-2
votes
1 answer

'ReverseManyToOneDescriptor' object has no attribute 'filter' Django

Hi there Im trying to retrieve a specific object from the related model so as to render data to my view specific to that particular object, in my case I have a custom user model and a related model called Seller. Models from django.db import…
Jordan Rob
  • 322
  • 2
  • 16
1 2 3
8
9