Opened 16 years ago
Closed 14 years ago
#12875 closed New feature (fixed)
Cannot redefine admin ordering dynamically
| Reported by: | Manuel Saelices | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.admin | Version: | 1.1 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | yes |
| Easy pickings: | no | UI/UX: | no |
Description
Sometimes you need redefine ordering dinamically, based in some logic at runtime
A example of that needed was this code:
class MyBaseAdmin(admin.ModelAdmin): def get_ordering(self, request): # I'd like i.e. a different order based on user or whatever if request.user.is_superuser(): ... return super(MyBaseAdmin, self).get_ordering(request)
Attachments (5)
Change History (13)
by , 16 years ago
| Attachment: | ticket_12875.diff added |
|---|
comment:1 by , 16 years ago
| Has patch: | set |
|---|---|
| Needs tests: | set |
| Triage Stage: | Unreviewed → Accepted |
by , 16 years ago
| Attachment: | ticket_12875_for_r12454_with_tests.diff added |
|---|
comment:2 by , 15 years ago
| Type: | → New feature |
|---|
comment:3 by , 15 years ago
| Severity: | → Normal |
|---|
comment:4 by , 14 years ago
| Easy pickings: | unset |
|---|---|
| UI/UX: | unset |
The patch is not working in last Django trunk [16339]. I will work on it.
by , 14 years ago
| Attachment: | ticket_12875_for_r16341.diff added |
|---|
A new patch with tests for the [16341] version
comment:5 by , 14 years ago
| Needs documentation: | set |
|---|---|
| Needs tests: | unset |
by , 14 years ago
| Attachment: | ticket_12875_for_r16341_with_docs.diff added |
|---|
comment:6 by , 14 years ago
| Needs documentation: | unset |
|---|---|
| Patch needs improvement: | set |
Looks good, except that the default get_ordering method should return self.ordering or () instead of checking all places.
by , 14 years ago
| Attachment: | ticket_12875_for_r16341_with_docs.2.diff added |
|---|
comment:7 by , 14 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
Note:
See TracTickets
for help on using tickets.
Patch with tests