Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#19120 closed Cleanup/optimization (fixed)

better document common behavior of readonly_fields and list_display

Reported by: EvilDMP Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

I was stunned to find that I could use a model's method as a readonly_field in admin. There doesn't seem to be any hint of this in the documentation - if there is, I have missed it.

It's a really useful bit of functionality, and can give valuable feedback to the user about the current state of the object they are editing, so I am quite surprised not to see it mentioned and explained more fully.

Also, although https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.fields says of it "New in Django 1.4: Please see the release notes" there's no mention of readonly_fields at https://docs.djangoproject.com/en/dev/releases/1.4/.

Finally, https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.readonly_fields doesn't mention "New in Django 1.4" - should it?

If I have understood this situation correctly, I'm happy to do some work on the relevant documentation.

Change History (6)

comment:1 Changed 2 years ago by ptone

  • Easy pickings set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from readonly_fields poorly documented to better document common behavior of readonly_fields and list_display
  • Triage Stage changed from Unreviewed to Accepted
  • Version changed from 1.4 to master

Thanks for offering feedback on the documentation.

readonly_fields were actually introduced in 1.2 - for 1.5 we removed notices for things added/changed in < 1.3

The behavior of using a method is explained in https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display

and the current readonly_field docs say: This option behaves nearly identical to ModelAdmin.list_display. - perhaps this could be more specific or clearer - so open to some rephrasing.

comment:2 Changed 2 years ago by EvilDMP

OK, I will see what I can come up with.

comment:3 Changed 2 years ago by EvilDMP

I have made a pull request: https://github.com/django/django/pull/459

comment:4 Changed 2 years ago by timo

  • Has patch set

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

  • Resolution set to fixed
  • Status changed from new to closed

In d1de7596b207b3a7dea8203334ef1739db3b1c94:

Fixed #19120 - Added an example of using ModelAdmin methods for read-only fields.

Thanks Daniele Procida for the patch.

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

In 75fb8f433fc0bc64fed0b8dcc540f7a3544f9aa4:

[1.5.X] Fixed #19120 - Added an example of using ModelAdmin methods for read-only fields.

Thanks Daniele Procida for the patch.

Backport of d1de7596b2 from master

Note: See TracTickets for help on using tickets.
Back to Top