Hi all

I'm testing newforms, but there is no much docs here, but searching in
django page docs, the code, tests and this list there is some
information, but I've found a problem and i don't know how to do it.
If someone could give me a tip I will be very grateful. :)

The model is something like:

class UserProfile(models.Model):
   user = models.OneToOneField(User)
   description = models.TextField()

class MemberDescription(models.Model):
   user = models.ForeignKey(UserProfile, related_name='member')
   gender = models.CharField(maxlength=1, choices=GENDER, core=True)
   birth = models.DateField()

The view is:

def manipulate_member(request, user_id=0):
   user_id = int(user_id)
   error_message = None
   if request.method == "POST":
       edit_form = MemberDescriptionForm(request.POST)
       if edit_form.is_valid():
           member = MemberDescription(**edit_form.clean_data)
           if user_id > 0 : member.id = user_id
           member.save()
           return HttpResponseRedirect("/profiles/member/edit/%i/" % member.id)
   elif user_id > 0:
       edit_form = MemberDescriptionForm(
MemberDescription.objects.get(id=user_id).__dict__)
   else:
       edit_form = MemberDescriptionForm()
   return render_to_response("profiles/member_form.html", {"form":
edit_form, 'user_id': user_id,'error_message': error_message})

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