On Wed, Apr 4, 2012 at 4:51 PM, Jaroslav Dobrek <jaroslav.dob...@gmail.com> wrote: >> 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. >> > > I had thought of this possibilty, too. I would prefer it, because it > is the simplest one. > But I don't understand how to find out in the save() function if the > admin has modified the field. > If I don't know this, the field will get the default value every time > an administrator saves the word.
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 -- 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.