Opened 4 years ago

Closed 4 years ago

#16641 closed Bug (duplicate)

Ordering not used on ForeignKeyField form field RadioSelect widget

Reported by: zyegfryed@… Owned by: nobody
Component: contrib.admin Version: 1.3
Severity: Normal Keywords: admin, ordering, foreignkey
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi,

I've spotted some inconsistency using the ordering option on Admin. By default, django.contrib.admin doesn't use the Admin ordering option when displaying a ForeignKeyField form field. However, when ordering is specified on model's Meta ordering option, the ordering appears.

Is that a bug or a feature ? Meaning : should the form field ordering follow the model's Meta definition, or should the admin's ordering option supersede the model's one ? (I thought about the later, thus this ticket.)

Example:

User(models.Model):
  class Meta:
    ordering = ('username', ) -> sort RadioSelect widget by username

UserAdmin(admin.ModelAdmin):
  ordering = ('username', ) -> sort only list view by username

Change History (2)

comment:1 Changed 4 years ago by zyegfryed@…

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Edit

User(models.Model):
  class Meta:
    ordering = ('username', ) -> sort RadioSelect widget by username. Comment this and ordering is no longer used even when specified in the following UserAdmin Admin definition.

UserAdmin(admin.ModelAdmin):
  ordering = ('username', ) -> sort only list view by username

Thanks for reviewing.

comment:2 Changed 4 years ago by julien

  • Resolution set to duplicate
  • Status changed from new to closed

This was already reported in #6585.

Note: See TracTickets for help on using tickets.
Back to Top