Monday, August 16, 2010

Re: Overriding ModelForm field's value in the admin changeview

The form and object are combined when you call:

response = super([YOURMODELFORMHERE], self).change_view(request,
object_id, extra_context=my_context)

You can see what the admin code for def change_view does in Django1.*/
django/contrib/admin/options.py

I was looking at the same thing and found an alternate route to for my
needs since I didn't need the value to be updated before the form was
rendered.

On Jul 14, 1:03 pm, Chuck Harmston <ch...@chuckharmston.com> wrote:
> Does anyone know where in the admin changeview the fields in a ModelForm is
> populated with the information from the database? I was hoping to override
> one of the fields in a subclassed ModelForm.__init__(), e.g.:
>
> self.base_fields[field_name].initial = 'foo'
>
> But the population appears to be happening farther down the chain, as 'foo'
> is overwritten with the value from the database.
>
> Thanks!

--
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate