Opened 17 years ago
Last modified 13 years ago
#7237 closed
Many-to-many relationship on self - inherited model — at Initial Version
Reported by: | zgollum | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Keywords: | qsrf-cleanup | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I've inherited django.contrib.auth.User model
class MyUser(User):
friends = models.ManyToManyField("self", symmetrical = False,
related_name = 'f_set')
objects = UserManager()
class Admin:
pass
Other fields were removed for simplicity.
Now I run shell and:
u1 = MyUser.objects.create_user(username='test1',
email='test1@…', password='test')
u2 = MyUser.objects.create_user(username='test2',
email='test2@…', password='test')
u1.friends.add(u2)
u1.friends.all()
RESULT(!):
[<MyUser: test1>]
u1.f_set.all()
[]
u2.f_set.all()
[<MyUser: test2>]
So, I guess it's a bug. If you add a u3 and add it to the friends of
u1:
u1.friends.all()
[<MyUser: test1>, <MyUser: test1>]