On Thu, Feb 5, 2009 at 2:08 PM, Silfheed <silfh...@gmail.com> wrote: > > No, not a direct cut and paste (I guess I should have) > > class person(models.Model): > gender = models.CharField(max_length=1, choices=(('M','male'), > ('F','female'))) > other = models.CharField(manx_length=20, null=True,blank=True) > > def save(self, force_insert=False, force_update=False): > if 'M' == self.gender: > self.other = 'Manly Man' > else: > self.other = 'Womanly Woman' > > super(person, self).save(force_insert, force_update > > The save works fine from the ./manage.py shell. It's only when I use > the admin page to add or create a person that it doesnt work. Am I > supposed to set up a form and use a form_save() as well or is the > above look correct? >
The above works, once the missing close paren is added and manx_length is changed to max_length on the 'other' field. I cut-and-pasted what you have into a test project, made those changes, and registered person with the admin. Then, when I add a person in the admin, the other field is set properly based on the gender value. So, I am not sure what is going on with your setup. The fact that you are not having trouble with manx_length suggests maybe this code is not actually the code being used when you are testing? Karen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---