#8825 closed (fixed)
Inherited ManyToMany-fields does not appear in edit forms
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Keywords: | ManyToMany inheritance new_fields | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Since revision [8855], inherited ManyToMany-fields does not appear in edit forms on the admin site.
Example models.py
:
from django.db import models from django.contrib import admin class Person(models.Model): name = models.CharField(max_length=64, blank=True, null=True) class BaseClass(models.Model): person = models.ManyToManyField(Person, related_name="%(class)s_person", blank=True, null=True) text = models.CharField(max_length=64, blank=True, null=True) class InheritedClass(BaseClass): status = models.CharField(max_length=64, blank=True, null=True) admin.site.register(InheritedClass)
In the example above, the person
field will appear in [8854], but disappear in [8855].
Attachments (2)
Change History (8)
by , 16 years ago
Attachment: | admin_inherited_m2m.diff added |
---|
comment:1 by , 16 years ago
milestone: | → 1.0 |
---|---|
Needs tests: | set |
Triage Stage: | Unreviewed → Accepted |
by , 16 years ago
comment:2 by , 16 years ago
Needs tests: | unset |
---|
added a test that shows the missing item from the class._meta.many_to_many after [8855] - passes in [8854], passes again after patch is applied
this does seem to be unique to admin though, if the patch is unapplied, the ManyToManyField
works fine in a shell, but isn't in the meta value for m2ms
though it probably affects ModelForm
itself also, since it likely reads the many_to_many attribute
comment:3 by , 16 years ago
Looks like this was a mistake I made in [8855]. I'll look at it in the morning if nobody else gets to it first.
comment:4 by , 16 years ago
The Django shell is often a bit too robust of an environment to test things like this. It sets everything up two or three times. The test suite is a better place to look for failures. The test I'm about to commit doesn't test the internal implementation, but, rather, the external interfaces. This is probably what cgrady was trying in the shell, but it fails quite immediately in the test suite.
comment:5 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
At this point in the process we need test cases for this type of change. A test that shows many-to-many fields not being available on a child model before the patch and then available afterward. This shouldn't be an admin-specific phenomenon.