Opened 7 years ago

Closed 7 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 7 years ago.
Adds a test and applies requested fixes to comments.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 7 years ago by Simon Charette

Triage Stage: UnreviewedAccepted

comment:2 Changed 7 years ago by Hasan Ramezani

Owner: changed from nobody to Hasan Ramezani
Status: newassigned

comment:3 Changed 7 years ago by Hasan Ramezani

Has patch: set

comment:4 Changed 7 years ago by Claude Paroz

Needs tests: set
Version: 1.8master

Changed 7 years ago by Aaron Elliot Ross

Adds a test and applies requested fixes to comments.

comment:5 Changed 7 years ago by Aaron Elliot Ross

Cc: aaronelliotross@… added
Needs tests: unset

comment:6 Changed 7 years ago by Tim Graham

Triage Stage: AcceptedReady for checkin

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

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