Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Validating dynamically generated forms
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
laun...@gmail.com  
View profile  
 More options May 9 2007, 11:33 am
From: Laun...@gmail.com
Date: Wed, 09 May 2007 08:33:11 -0700
Local: Wed, May 9 2007 11:33 am
Subject: Validating dynamically generated forms
Hi,

I have built this class:

class FormClass(forms.Form):
   def __init__(self, *args, **kwargs):
      super(FormClass, self).__init__(*args, **kwargs)
      # Get tags and their id
      for t in Item.objects.get(pk=id).tags.values():
         field_id = t['id'] # tag ID is the form's field name
         self.fields[field_id] = forms.IntegerField(min_value=1, label
= t['name'])

This class generates a dynamic form, based on the tags attached to an
item.

if request.POST:
   form = FormClass(request.POST)
   if form.is_valid():
   # save the information
else:
   form = FormClass()

# render it all to a template

Upon entering (correct) data, the form validation throws error:
supposedly the fields are empty.

What am I doing wrong here?

Many thanks in advance,

Laundro


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ReluctantStranger@gmail.c om  
View profile  
 More options May 10 2007, 11:58 am
From: "ReluctantStran...@gmail.com" <ReluctantStran...@gmail.com>
Date: Thu, 10 May 2007 08:58:46 -0700
Local: Thurs, May 10 2007 11:58 am
Subject: Re: Validating dynamically generated forms
I didn't examine your code but I suggest using form_for_instance or
form_for_model to generate a dynamic form from a django app model.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
dball...@gmail.com  
View profile  
 More options May 10 2007, 1:43 pm
From: dball...@gmail.com
Date: Thu, 10 May 2007 10:43:01 -0700
Local: Thurs, May 10 2007 1:43 pm
Subject: Re: Validating dynamically generated forms
The problem appears to be because you are using a numeric key as field
name.
change this:  field_id = t['id']   to  field_id = str(t['id']) , or
use a real string as the name.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »