Adding readonly fields

14 views
Skip to first unread message

asdfg

unread,
Dec 1, 2011, 4:32:39 AM12/1/11
to django-...@googlegroups.com
I've added some additional fields to models.py and updated admin/__init__.py so they show up on the admin pages. This all works fine. However, I want to show one of these fields as a readonly field using the readonly_fields option. However, when I add this in, the field value shows up as a dictionary of the field parameters e.g. {'label': 'My field', 'name': 'myfield', 'help_text': 'Some help text'}

There's clearly something else going on in the pages app that's causing this to break as it works fine elsewhere, but I haven't a clue where to start looking!

Has anyone else come across this, resolved it, or have any ideas what might be causing it and how to get around it?

asdfg

unread,
Dec 1, 2011, 5:36:01 AM12/1/11
to django-...@googlegroups.com
Ah, the answer was simpler than I expected - just needed to add an {% if field.is_readonly %} option into pages/templates/admin/pages/page/include/fieldset.html - basically copied exactly what's in the default Django version of this file and it works.

I guess this ought to be added into django-page-cms as standard...
Reply all
Reply to author
Forward
0 new messages