Open thmsrmbld opened 3 years ago
Just a personal preference - it's possible to use @admin.register decorator for Admin files, which stops you having to have long blocks of redundant code such as in this file: https://github.com/bsassoli/milan_culture_map/blob/main/venues/admin.py
Where you have:
admin.site.register(User, UserAdmin) admin.site.register(Venue, VenueAdmin) admin.site.register(Category) admin.site.register(Event) admin.site.register(News) admin.site.register(VManager) admin.site.register(Map)
You could replace this with an in-line decorator for each admin.ModelAdmin instance - an example from one of my own projects:
@admin.register(SurveyElement) class SurveyElementAdmin(admin.ModelAdmin): list_display = ( "survey", "element_title", "section_title", "section_number", "type", "order", "updated", )
(I see this more frequently than your style - but your style isn't wrong - this just feels more structured to me)
Amazing, thank you.
Just a personal preference - it's possible to use @admin.register decorator for Admin files, which stops you having to have long blocks of redundant code such as in this file: https://github.com/bsassoli/milan_culture_map/blob/main/venues/admin.py
Where you have:
You could replace this with an in-line decorator for each admin.ModelAdmin instance - an example from one of my own projects:
(I see this more frequently than your style - but your style isn't wrong - this just feels more structured to me)