One more comment:

You would also want to make sure that the init method of SampleForm
populates the non-model fields (ie. lastname) with the correct values.

class SampleForm(forms.ModelForm):

   lastname = form.CharField...

   def  __init__(self, *args, **kwargs):
      super(SampleForm, self).__init__(self, *args, **kwargs)
      ...
      self.fields['lastname'].initial = ...

On Jan 8, 3:14 am, Andy <aat...@gmail.com> wrote:
> The better approach would be to specify a custom form in your
> ModelAdmin.  This way your fieldset definition could include anything
> that's specified in your custom form.
>
> For Example:
>
> class SampleModel(models.Model):
>
>    email = models.EmailField...
>    firstname = models.CharField...
>
> class SampleForm(forms.ModelForm):
>
>    lastname = form.CharField...
>
> class SampleModelAdmin(admin.ModelAdmin)
>
>    fieldsets = (('General Info', {'fields' : ('email', 'firstname',
> 'lastname')}),)
>    form = SampleForm
>
> You would just have to override save_model to ensure that it does the
> appropriate things with the additional fields.
>
> On Jan 7, 9:44 am, EagerToUnderstand <truh...@gmail.com> wrote:
>
> > Thanks Karen & Daniel,
>
> > I think your overiding approach will work.  Thank you.
>
> > Implemented a work around.  I added extra fields (that persist my
> > method information) to my model that I update and save when I do a
> > listing.  Price I pay is an extra database update each time the model
> > is getting listed.
> > Will see how it influence performance.
>
> > Thank you for your replies.
--~--~---------~--~----~------------~-------~--~----~
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