#25374: Admin system check prevents dynamic ModelAdmin attributes
-------------------------------+--------------------------------------
     Reporter:  mbox           |                    Owner:  nobody
         Type:  Bug            |                   Status:  new
    Component:  contrib.admin  |                  Version:  master
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  1              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------
Changes (by charettes):

 * cc: charettes (added)


Comment:

 The main argument I see about running checks against instance instead of
 subclasses of `ModelAdmin` is the fact they are the actual objects that
 registered to the site, Django doesn't actually use `ModelAdmin` classes
 directly. This would be consistent with how checks are ran against
 `db.Field` instance compared to `db.Models` classes.

 If you take a look at the admin check methods signatures you can clearly
 see most of them can't be performed if they are not provided the
 `db.Model` the `ModelAdmin` must be bound to. The model bounding is
 something that happens at `ModelAdmin` initialization compared to
 `InlineModelAdmin` which is done at class definition. I think it would
 make more sense to run these checks against "bound" objects instead which
 is `ModelAdmin` instances and `InlineModelAdmin` classes.

 I would also argue that string representation of `ModelAdmin` should be
 changed to the reflect its full class path and the model it's bound to
 instead of its bound model `app_label` and the class name which doesn't
 make much sense anyway. Combined with the proposed changes it should make
 it easier to identify the check offending `ModelAdmin` instance given the
 `db.Model` it's bound to is displayed.

 As Tim said It wouldn't hurt writing to the mailing list to get extra
 feedback but IMHO we should tentatively accept this ticket as a
 cleanup/optimization of the admin checks.

--
Ticket URL: <https://code.djangoproject.com/ticket/25374#comment:5>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/062.deec286cf1c6644d830ac64c48a4898f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to