Opened 17 years ago
Closed 12 years ago
#6585 closed Bug (fixed)
admin foreignkey dropdown does not adhere to model's admin ordering
Reported by: | Gary Wilson | Owned by: | fisadev |
---|---|---|---|
Component: | contrib.admin | Version: | newforms-admin |
Severity: | Normal | Keywords: | #sprints-django-ar |
Cc: | DJango@…, Brillgen Developers, sebastien@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This doesn't set ordering in the dropdown (but I would expect it to):
class Admin: ordering = ('last_name',)
Meta ordering, however, does work:
class Meta: ordering = ('last_name',)
Change History (17)
comment:1 by , 17 years ago
Keywords: | nfa-someday added |
---|---|
Needs documentation: | set |
Needs tests: | set |
Triage Stage: | Unreviewed → Someday/Maybe |
Version: | SVN → newforms-admin |
comment:2 by , 17 years ago
Cc: | added |
---|
comment:3 by , 14 years ago
Type: | → Bug |
---|
comment:4 by , 14 years ago
Cc: | added |
---|---|
Severity: | → Normal |
As a simpler and more flexible fix, would it be better if we had a field called let's say related_ordering = { 'fk_field_name': 'order_field' } ...this would allow diff. models to have diff order in FK drop down. I can contribute this patch if this direction gets blessed.
comment:4 by , 14 years ago
Severity: | → Normal |
---|
Wouldn't it be extremely simple to add an admin field called let's say
related_ordering = {'field_name': 'order_field'}
in the admin model in which the foreign key is instead of looking it up from the admin of the foreign key model?
That should make this a much simpler implementation while having flexibility to have different order in different model admins which have the foreign key to the same model but need different order in drop down.
comment:5 by , 14 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
Triage Stage: | Someday/Maybe → Design decision needed |
Changing stage to get this direction of coding blessed by the community...want to avoid working on a patch if the design itself is not ok with everyone...
comment:6 by , 14 years ago
Resolution: | needsinfo |
---|---|
Status: | closed → reopened |
comment:7 by , 13 years ago
Easy pickings: | unset |
---|
Taking responsibility for this suggestion (by being logged in while commenting ;) :
Wouldn't it be extremely simple to add an admin field called let's say
related_ordering = {'field_name': 'order_field'}
in the admin model in which the foreign key is instead of looking it up from the admin of the foreign key model?
That should make this a much simpler implementation while having flexibility to have different order in different model admins which have the foreign key to the same model but need different order in drop down.
comment:9 by , 13 years ago
Cc: | added |
---|
comment:10 by , 13 years ago
Keywords: | nfa-someday removed |
---|---|
Triage Stage: | Design decision needed → Accepted |
The original report here is correct, the ModelAdmin ordering should take precedence if set, even for related-field dropdowns. We don't need to add additional complexity in the form of new options specifically for related fields; customization at that level is already possible by overriding methods on the ModelAdmin of the model with the FK.
comment:11 by , 13 years ago
Owner: | changed from | to
---|---|
Status: | reopened → new |
comment:12 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:13 by , 12 years ago
Has patch: | set |
---|---|
Needs tests: | unset |
Proposed implementation on pull request 806:
comment:15 by , 12 years ago
Keywords: | #sprints-django-ar added |
---|
comment:16 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Marking it as someday. It is quite a tricky thing to inside newforms-admin and we need to wait for the code to mature a bit.