#33258: inconsistent use of () and [] for attributes in Admin class - Also class
variables
------------------------------------------+------------------------
               Reporter:  newearthmartin  |          Owner:  nobody
                   Type:  Bug             |         Status:  new
              Component:  contrib.admin   |        Version:  3.2
               Severity:  Normal          |       Keywords:  Admin
           Triage Stage:  Unreviewed      |      Has patch:  0
    Needs documentation:  0               |    Needs tests:  0
Patch needs improvement:  0               |  Easy pickings:  0
                  UI/UX:  0               |
------------------------------------------+------------------------
 In Django's Admin class, most "lists" are initialized as tuples `()` while
 two of them (`inlines` and `actions`)are initialized as lists `[]`

 ```
 list_display = ('__str__',)
 list_display_links = ()
 list_filter = ()
 ...
 list_editable = ()
 search_fields = ()
 ...
 inlines = []
 ...
 actions = []
 ```

 This is inconsistent.

 And also there is a Since these are declared in the class, they are shared
 among all instances if this value is not set.

 I wanted to add an action to an admin subclass so I did
 `MyAdmin.actions.append('some_action')` which added this action to all my
 admins who had not set a new value to `actions`. While lists are more
 semantically correct than tuples, tuples have the advantage of being
 immutable, so they force users to reset the value every time.

 So, two solutions:

 - declare all these attributes as instance variables in the constructor.
 Possibly setting them all as lists
 - declare all these attributes as tuples, keeping them where they are

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33258>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/057.714a57d652fd1970fe93f61cabe5a6b1%40djangoproject.com.

Reply via email to