Friday, February 4, 2011

Admin change view and extra form field.

I have an AdminModel with an overridden form, just for having an extra
form field called 'limit'.

This field 'limit' is stored in a separated model. Until here I
haven't any problem.

Now I want to show the saved 'limit' value when I am on admin
change_view. Unfortunately the admin change_view method hasn't a form
as a parameters.
it has: self, request, object_id, extra_context=None.

Is there a way to show the saved 'limit' value without the need of
copy&paste the entire change_view method for only change this single
line:

form = ModelForm(instance=obj)

for

form = ModelForm(instance=obj, initial={'limit':get_limit(obj)})

thanks!
--
Marc

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment