Questions tagged [manyrelatedmanager]
9 questions
10
votes
4 answers
How to check the type of a many-to-many-field in django?
How can you check the type of a many-to-many-field in django?
I wanted to do it this way:
import django
field.__class__ == django.db.models.fields.related.ManyRelatedManager
This doesn't work, because the class ManyRelatedManager can't be…

amann
- 5,449
- 4
- 38
- 46
5
votes
1 answer
Django How to use ManyRelatedManager
I have 2 apps that are distinct and have no particular reason to talk to each other.
This means I don't want to import either name in either app. All the work should be
within a glue app.
I would like to write a glue app that would join to…

Narsilou
- 321
- 1
- 2
- 6
2
votes
1 answer
How to update a M2M field in django via AJAX call
I am building a user profile in django, where I want the user to enter his skill set. The skill field is a ManyToMany field to a model name Skills. Below is shown the models.py file
class UserProfile(models.Model):
name =…

Sachin
- 3,672
- 9
- 55
- 96
1
vote
0 answers
Use Non default database with ManyRelatedManager methods in django
I want to use a non default database with ManyRelatedManager's set method in django.
I have tried the following methods:
By mentioning the using method in the query
It gives me the following error:
AttributeError: 'QuerySet' object has no attribute…

Aakash Nihalani
- 75
- 1
- 9
1
vote
0 answers
Django values on m2m field doesn't return the same as same query on base Model
I expect a behaviour I'm not obtaining. Consider this example model:
class Node(models.Model):
name = models.CharField(max_length=30) # Verbose for readability
class SpecialNode(Node):
other_attr = models.CharField(max_length=30)
class…

Marc Bernardo
- 11
- 1
1
vote
1 answer
Django: ManyRelatedManager is not Callable
I have a site with users who can take terms at University:
class Term(models.Model):
school = models.ForeignKey(School)
name = models.CharField(max_length=200)
isPrimaryTerm = models.BooleanField()
date = models.DateField()
class…

Nick Heiner
- 119,074
- 188
- 476
- 699
0
votes
0 answers
TypeError: Direct assignment to the forward side of a many-to-many set is prohibited. Use technicians.set() instead
I keep getting this very same type error even though I am using set. Can someone maybe point out what I'm doing wrong in my api endpoint?
views.py
@require_http_methods(["GET", "POST"])
def api_requerimientos(request):
if request.method ==…

Joyce
- 1
- 2
0
votes
2 answers
How to use add(), set() and clear() methods of ManyRelatedManager in Django ManyToManyField with a through class?
I have models as follows,
Class Bank(models.Model):
customers = models.ManyToManyField(Customer,'banks', through='bank_customer')
Class Customer(models.Model):
name = models.CharField(max_length=50)
Class Bank_customer(models.Model):
…

Vikramark
- 137
- 13
0
votes
2 answers
Override instance attribute
In views.py I have:
my_computer = Computer.objects.get(pk=some_value)
The computer object has a field called projects that's a ManyRelatedManager.
Calling
my_projects = my_computer.projects.all()
will set the value of my_projects to a list of…

Ionut Hulub
- 6,180
- 5
- 26
- 55