Django

Code

Ticket #7237 (closed: worksforme)

Opened 2 months ago

Last modified 6 days ago

Many-to-many relationship on self - inherited model

Reported by: zgollum Assigned to: nobody
Milestone: 1.0 Component: Core framework
Version: SVN Keywords: qsrf-cleanup
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description (Last modified by ramiro)

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@test.com', password='test')
u2 = MyUser.objects.create_user(username='test2',
email='test2@test.com', 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>] 

Attachments

Change History

06/10/08 09:59:58 changed by gav

  • keywords set to qsrf-cleanup.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

06/16/08 11:03:28 changed by ramiro

  • description changed.

06/16/08 12:10:45 changed by jacob

  • milestone set to 1.0.

06/29/08 06:27:29 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to worksforme.

Using exactly the example given here, this works fine for me with [7786] (it may well have been fixed as a side-effect of something else between the time or reporting and now). Please reopen if you are still seeing the problem, preferably with a patch against tests/regressiontests/model_inheritance_regress/models.py that shows a failing test.

07/01/08 06:37:05 changed by zgollum

Works! Great, thanks. I just knew that everything was going to be alright when Mike's back :)


Add/Change #7237 (Many-to-many relationship on self - inherited model)




Change Properties
Action