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
save() happens before the data is saved to the database (well, its the
last things that happens in Model.save()). So you can pull the
original data from the database, and compare it to the one you are
being asked to save.
However, I don't think you need to do this at all. I would say you
would only populate the other fields if they are all empty, and the
base is not empty. If the other fields are not empty, either it has
already been pre-populated, or it has been filled in manually, and you
should not change it. Seems pretty straightforward!
Cheers
Tom
I'm not sure I clearly understood your issue.
Do you want some choice fields to limit their choices according to another choice field value ?
Regards,
Xavier.
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>