#11750 closed (worksforme)
ManyToMany field does not respect Proxy models
Reported by: | mxposed | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.1 |
Severity: | Keywords: | manytomany proxy | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi
I have a proxy model above django.contrib.auth.models.User
and i have a ManyToMany field referencing to django.contrib.auth.models.User
When i try to add an instance of my proxy class to the field i get the TypeError: 'user' instance expected
class MyUser(User): class Meta:ΒΆ proxy = True class Item(models.Model): owners = models.ManyToManyField(User) Item.objects.get(fk=1).owners.add(MyUser.objects.get(fk=1))
Change History (2)
comment:1 by , 15 years ago
Resolution: | β worksforme |
---|---|
Status: | new β closed |
comment:2 by , 15 years ago
There's an error in my test: a_set
should point to User
. But still not reproducible.
import unittest from django.db import models from django.contrib.auth.models import User class A(User): class Meta: proxy=True class B(models.Model): a_set = models.ManyToManyField(User) class T11750(unittest.TestCase): def test_11750(self): user = User.objects.create(username="foo") a = A.objects.get() b = B.objects.create() b.a_set.add(a)
Note:
See TracTickets
for help on using tickets.
I cannot reproduce this with r11638.