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. I think I'm in for a good documentation reading... thanks for
your guidance Jashugan.
Bastien
On Jun 3, 5:11 pm, Jashugan <jashu...@gmail.com> wrote:
> On Jun 3, 2:09 am, Bastien <bastien.roche...@gmail.com> wrote:
>
> > Hi,
>
> > I have a form where the user chooses her activity and then I
> > automatically fill the category field in the database according to her
> > activity. My question is where should live the code that do that? I
> > want it to be triggered once the user hits the submit button of the
> > form, I take the activity of the user, check in which category it is
> > and set the category field.
>
> Personally I create a save field on the form (just like it was a model
> form). Then my view code looks like:
>
> ## views.py
>
> if request.method == 'POST':
>   form = MyForm(request.POST)
>   if form.is_valid():
>     form.save()
>     # redirect as usual
>
> ## forms.py
>
> class MyForm(forms.Form):
>   activity = forms.CharField()
>
>   def save(self):
>     # do your saving here
--~--~---------~--~----~------------~-------~--~----~
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