Opened 9 years ago

Closed 9 years ago

#25688 closed Cleanup/optimization (fixed)

admin.register shouldn't allow an empty list of models to be registered

Reported by: Baptiste Mispelon Owned by: Hasan Ramezani
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: aaronelliotross@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

I couldn't remember how to do the model registering using the decorator syntax and ended up with this code:

@admin.register()
class MyModelAdmin(admin.ModelAdmin):
    pass

This code doesn't actually do anything, but it does so silently. I think register should complain when you give it no actual model to register.

Attachments (1)

empty_list_fails_to_register.diff (1.5 KB ) - added by Aaron Elliot Ross 9 years ago.
Adds a test and applies requested fixes to comments.

Download all attachments as: .zip

Change History (8)

comment:1 by Simon Charette, 9 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Hasan Ramezani, 9 years ago

Owner: changed from nobody to Hasan Ramezani
Status: newassigned

comment:3 by Hasan Ramezani, 9 years ago

Has patch: set

comment:4 by Claude Paroz, 9 years ago

Needs tests: set
Version: 1.8master

by Aaron Elliot Ross, 9 years ago

Adds a test and applies requested fixes to comments.

comment:5 by Aaron Elliot Ross, 9 years ago

Cc: aaronelliotross@… added
Needs tests: unset

comment:6 by Tim Graham, 9 years ago

Triage Stage: AcceptedReady for checkin

comment:7 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 8c553e7d:

Fixed #25688 -- Made admin.register() disallow an empty list of models.

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