On Wed, Apr 4, 2012 at 2:09 PM, Jaroslav Dobrek
<jaroslav.dob...@gmail.com> wrote:
> Hello,
>
> is there a way to calculate default values for certain fields based
> on the content of other fields?
>
> […]
>
> Any ideas how to realize this?
>
> Jaroslav

Three ways immediately spring to mind.

You could override Model.save() on the model you wish to calculate
fields for. This could populate the fields if they are not already
populated and the instance has a base adjective.

Similar, but not the same, you could add a pre_save signal to that
model which does the same thing. The pre_save signal is emitted as
part of Model.save(), so you can see how similar it is.

Finally, you could leave the model unmodified, and simply make an AJAX
service for generating the various adjective forms, and hook that into
a custom admin form, adding a widget that collects the adjective from
the un-submitted form, calls the AJAX service, and populates the
appropriate fields.

Cheers

Tom

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to