#13233: readonly_fields doesn't work with fields not part of the model
------------------------------------+---------------------------------------
Reporter: benc | Owner: nobody
Status: new | Milestone:
Component: django.contrib.admin | Version: 1.2-beta
Keywords: admin, readonly_fields | Stage: Unreviewed
Has_patch: 0 |
------------------------------------+---------------------------------------
using readonly_fields in the admin works for fields of the model
but when I add a field to the form and try to make it readonly I'm getting
an error:
{{{
ImproperlyConfigured at /admin/myapp/mymodel/1/
MyModelAdmin.readonly_fields[0], 'somefield' is not a callable or an
attribute of 'MyModelAdmin' or found in the model 'MyModel'.
}}}
readonly_fields is useful to show calculated fields.
I'm using it to show the sum of inline cart items.
{{{
class MyModelAdminForm(forms.ModelForm):
class Meta:
model = MyModel
somefield = forms.CharField()
class MyModelAdmin(admin.ModelAdmin):
form = MyModelAdminForm
readonly_fields = ('somefield',)
}}}
Thanks
--
Ticket URL: <http://code.djangoproject.com/ticket/13233>
Django <http://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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.