On 01/04/2008, timc3 <[EMAIL PROTECTED]> wrote:
>  I thought that I could add in some additional information to a form
>  before it gets saved as a new object in the database but the following
>  isn't working:
>
>  def groupadd(request):
>
>     if request.method == 'POST':
>         form = GroupForm(request.POST)
>         if form.is_valid():
>             data = form.cleaned_data
>             data['group_owner'] = request.user.id
>             data['group_members'] = request.user.id
>             data['group_admins'] = request.user.id
>
>             newform = GroupForm(data)
>             newform.save

Is this a typo or do you really have newform.save and not newform.save()?
If so then that is one of your problems since you are not actualling calling
the save method, just returning its type.

>  It doesn't return any error and it doesn't save the new object.  Is
>  there anyway of sending additional data with a form?

I believe the better way to achieve what you are trying to do is:

       if form.is_valid():
          newgroup = form.save(commit=False)
          newgroup.group_owner = request.user.id
          newgroup.group_members = request.user.id
          newgroup.group_admins = request.user.id

          newgroup.save()
          return HttpResponseRedirect("/group/list/")

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to