On Jun 3, 8:20 am, Bastien <bastien.roche...@gmail.com> wrote:
> Yes it seems to be the logical solution. And does this override the
> save() method? I guess yes so I'll have to save the entire form by
> hand.
Well it only overrides the save method if you are using a ModelForm.
If you are, then you don't need to necessarily do all the saving by
hand.  You would just call the super method, like so:

def save(self, *args, **kwargs):
  instance = super(MyForm, self).save(*args, **kwargs)
  category, created = Category.objects.get_or_create
(name=self.cleaned_data['activity'])
  instance.category = category
  instance.save()

--~--~---------~--~----~------------~-------~--~----~
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