ModelAdmin.readonly_fields isn't graceful with filefields.
|Reported by:||Owned by:||Paul Collins|
|Severity:||Normal||Keywords:||feature admin readonly filefield|
|Cc:||kez.knight@…, adam@…, thepapermen, riccardo.magliocchetti@…, cmawebsite@…||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Currently, if supplying a FileField (and presumably, an ImageField or anything subclassing FileField) in the list of readonly_fields on a ModelAdmin instance, the value stored against the database (the path to its location on the filesystem or storage backend) is displayed as plain text.
It would be neater if instead, it displayed an HTML link of path, as it does when displaying the standard file upload widget in a non-readonly context (though excepting the file upload field itself). This would allow for more intuitive handling of admin access to read-only forms with additional data (eg: downloading uploaded PDFs, which is the use-case I'm facing at the moment.)
Looking at the source, I think the place to tackle this would be AdminReadonlyField.contents() in source:django/trunk/django/contrib/admin/helpers.py but that is just a cursory glance.
Obviously, low priority feature request, rather than a bug.
Change History (40)
comment:1 Changed 6 years ago by
|Patch needs improvement:||unset|
comment:2 Changed 6 years ago by
|Component:||Contrib apps → django.contrib.admin|
|Triage Stage:||Unreviewed → Accepted|
comment:6 Changed 5 years ago by
|Owner:||changed from nobody to Adam J. Forster|
|Status:||new → assigned|
comment:13 Changed 5 years ago by
|Owner:||changed from Adam J. Forster to Paul Collins|
|Status:||assigned → new|