Opened 16 years ago
Closed 14 years ago
#8161 closed Bug (invalid)
ManyToManyField with relation to self not saved in admin when using inheritance
Reported by: | Mathijs de Bruin | Owned by: | Jonas Obrist |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | newforms newforms-admin admin inheritance manytomany self |
Cc: | drbob@…, madhusudancs@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In the following example code, the 'links' field does not get saved in the admin for ChildModel
:
class ParentModel(models.Model): slug = models.SlugField() # For some reason, changes do not get saved (anymore) links = models.ManyToManyField('self', related_name='links', null=True, blank=True) def __unicode__(self): return self.slug class ChildModel(ParentModel): text = models.TextField()
The admin is registred simply by using:
admin.site.register(ChildModel)
It seems to me this is a bug in either the newforms Admin or newforms.
Change History (11)
comment:1 by , 16 years ago
Cc: | added |
---|
comment:2 by , 16 years ago
milestone: | → 1.0 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
follow-up: 4 comment:3 by , 16 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
Fat fingers i guess. Only wanted to accept that one.
comment:5 by , 16 years ago
milestone: | 1.0 → post-1.0 |
---|
Lack of activity/patch here, and the fact that it's a relatively uncommon case suggests this probably can be handled post-1.0.
comment:7 by , 16 years ago
Component: | Core framework → Database layer (models, ORM) |
---|
With the same code piece I just inserted test1 test2 test3 as slug field values for ParentModel and testc1 testc2 and testc3 for ChildModel and linked testc2 to testc1 and testc3 to testc2
The bug is not just in the admin, it happens on the interactive interpreter too. This is the small piece of test code on the interpreter.
from dummy.testapp.models import ChildModel, ParentModel
ChildModel.objects.all()
[<ChildModel: testc1>, <ChildModel: testc2>, <ChildModel: testc3>]
ParentModel.objects.all()
[<ParentModel: test1>, <ParentModel: tes2>, <ParentModel: test3>, <ParentModel: testc1>, <ParentModel: testc2>, <ParentModel: testc3>]
c2 = ChildModel.objects.get(slug='testc2')
c2.links
<django.db.models.fields.related.ManyRelatedManager object at 0x99c490c>
c2.links.all()
[]
c1 = ChildModel.objects.get(slug='testc1')
c1.links.all()
[<ParentModel: testc2>, <ParentModel: testc3>]
c3 = ChildModel.objects.get(slug='testc3')
c3.links.all()
[]
So I suppose this bug is not just in admin Interface but in the ORM itself. So I change the component. Can some one help me track this bug and fix it? As in how to go about? Where to look for the code?
comment:8 by , 16 years ago
Cc: | added |
---|---|
Version: | 1.0-alpha → SVN |
comment:9 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:10 by , 14 years ago
Easy pickings: | unset |
---|---|
Owner: | changed from | to
UI/UX: | unset |
comment:11 by , 14 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
can't reproduce, ran both admin and the python code.
A specific ChildModel seems only to save itself as a link, refuses to save every other child.