grr.. cut and paste and I still leave off the last parenthesis...
        super(person, self).save(force_insert, force_update)

Anyway, the code is syntactically correct, I just tried it out in a
little test environment I set up.

Thanks again

On Feb 5, 11:08 am, 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?
>
> Thanks
>
> On Feb 4, 8:55 pm, Karen Tracey <kmtra...@gmail.com> wrote:
>
> > On Wed, Feb 4, 2009 at 11:39 PM, Silfheed <silfh...@gmail.com> wrote:
>
> > > Heyas
>
> > > So I'm sure this is pretty basic, but I don't seem to be able to get
> > > the following to work and I cant seem to find suitable info on google
> > > or the django site.
>
> > > I've got my model:
>
> > > 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 issue is whenever I update or create a 'person' in the django
> > > admin site, it doesnt seem to call my save().  Am I missing
> > > something?  I've not looked into signals but I thought that overriding
> > > save() still worked, just that signals were for removing non-save like
> > > operations from the save() fn (ie send email on save).
>
> > > Anyway, it's late and I'm probably missing something basic, but I've
> > > been searching the net for a while now and just cant seem to get it to
> > > work.
>
> > If that's a cut and paste, your def save is not indented under class person,
> > so its just a function, not a save() method for the person class.
>
> > 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to