Re: Newforms Admin - Overriding the Save Method of a ModelForm
Thanks Brian, Reposted: http://groups.google.com/group/django-users/t/2ccf2bb1dc06058e On Jul 2, 8:47 am, Brian Rosner <[EMAIL PROTECTED]> wrote: > On Jul 2, 2008, at 9:08 AM, John Boxall wrote: > > > > > But in NFA - it seems the save method isn't called! > > It works for me. If the print statement is not working then see about > tracking it down and post a detailed ticket with what is happening. > Also you will want to make sure you are returning the value from the > super call. The parent save method will return an instance that is > needed else where in the newforms-admin views. > > A quick side note, it is best to ask these question on the django- > users mailing list. django-developers is meant for the development of > Django. > > Brian Rosnerhttp://oebfare.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~--~~~~--~~--~--~---
Re: Newforms Admin - Overriding the Save Method of a ModelForm
Hey Marc - that's what I thought! But in NFA - it seems the save method isn't called! For instance: class ModelUserAdmin(admin.ModelAdmin): form = ModelUserForm ... class ModelUserForm(forms.ModelForm): def clean(self): # This method will successfully be called from the add_view or change_view # of NFA print 'ModelUserForm >>> clean()' super(ModelUserForm, self).clean() def save(self, commit=True): # This method -WILL NOT- be called from the add_view or change_view # of NFA - but I would like it to be! print 'ModelUserForm >>> save()' super(ModelUserForm, self).save(commit) On Jul 2, 3:50 am, Marc Garcia <[EMAIL PROTECTED]> wrote: > Sure, > > just remember to return > > super(YourModelForm, self).save(commit) > > in it. > > On Jul 2, 9:10 am, John Boxall <[EMAIL PROTECTED]> wrote: > > > Hi everyone! > > > I'm just trying out newforms admin - it's fantastic. I can't wait > > until this makes it's way into trunk - > > > A question - > > I'd like to add custom behavior when a object is saved in the admin > > console. > > > I'm following this example of how to add custom behaviour to validate > > an > > object:http://code.djangoproject.com/wiki/NewformsHOWTO#Q:HowdoIaddcustomval... > > > I would expect to be able to add a save() method to my ModelForm and > > have it be called when I hit save... how ever this does not seem to be > > the case! > > > Has anyone had any luck overriding the save method of a model form in > > NFA? > > > Cheers, > > > John --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~--~~~~--~~--~--~---
Newforms Admin - Overriding the Save Method of a ModelForm
Hi everyone! I'm just trying out newforms admin - it's fantastic. I can't wait until this makes it's way into trunk - A question - I'd like to add custom behavior when a object is saved in the admin console. I'm following this example of how to add custom behaviour to validate an object: http://code.djangoproject.com/wiki/NewformsHOWTO#Q:HowdoIaddcustomvalidation I would expect to be able to add a save() method to my ModelForm and have it be called when I hit save... how ever this does not seem to be the case! Has anyone had any luck overriding the save method of a model form in NFA? Cheers, John --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~--~~~~--~~--~--~---