Re: Missing something obvious? Question about forms

2012-01-18 Thread kenneth gonsalves
On Wed, 2012-01-18 at 09:42 -0500, Jeff Heard wrote:
> but there is no "ListField"  How is this normally handled? 
> 
multiplechoicefield?
-- 
regards
Kenneth Gonsalves

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



Re: Missing something obvious? Question about forms

2012-01-18 Thread Jeff Heard
There is no presentation layer, actually.  I mean, theoretically the forms
could be rendered, but I really just want them to validate input data AND..
and this is the kicker, AND I need them to provide default values, which
Forms as I understand, don't do, except for presentation.  As in, when I
pull form_instance.count, it should be 1, even if nothing was specified in
the GET dictionary.  It's not my standard...

-- Jeff

On Wed, Jan 18, 2012 at 11:06 AM, Tom Evans wrote:

> That would probably do it. You may also need to give it a different
> widget, I'd guess that a  is not how you would present this to
> the user - although maybe you are just using the form for processing
> and not to generate a presentation layer.
>
> Cheers
>
> Tom
>
> On Wed, Jan 18, 2012 at 4:01 PM, Jeff Heard 
> wrote:
> > Sadly these strings are arbitrary, yes...  I suppose I could subclass
> > MultipleChoiceField and kill the validator.
> >
> > On Wed, Jan 18, 2012 at 10:54 AM, Tom Evans 
> > wrote:
> >>
> >> On Wed, Jan 18, 2012 at 3:51 PM, Andre Terra 
> wrote:
> >> > https://docs.djangoproject.com/en/dev/ref/forms/fields/#choicefield
> >> >
> >> >
> https://docs.djangoproject.com/en/dev/ref/forms/fields/#django.forms.MultipleChoiceField
> >> >
> >> >
> >>
> >> That is how I almost replied, but a MultipleChoiceField constrains the
> >> submitted values to be within a predefined list of acceptable values.
> >> You couldn't use a MultipleChoiceField to collect an arbitrary number
> >> of arbitrary strings, it would fail validation.
> >>
> >> Cheers
> >>
> >> Tom
> >>
> >> --
> >> 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.
> >>
> >
> > --
> > 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.
>
> --
> 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.
>
>

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



Re: Missing something obvious? Question about forms

2012-01-18 Thread Tom Evans
That would probably do it. You may also need to give it a different
widget, I'd guess that a  is not how you would present this to
the user - although maybe you are just using the form for processing
and not to generate a presentation layer.

Cheers

Tom

On Wed, Jan 18, 2012 at 4:01 PM, Jeff Heard  wrote:
> Sadly these strings are arbitrary, yes...  I suppose I could subclass
> MultipleChoiceField and kill the validator.
>
> On Wed, Jan 18, 2012 at 10:54 AM, Tom Evans 
> wrote:
>>
>> On Wed, Jan 18, 2012 at 3:51 PM, Andre Terra  wrote:
>> > https://docs.djangoproject.com/en/dev/ref/forms/fields/#choicefield
>> >
>> > https://docs.djangoproject.com/en/dev/ref/forms/fields/#django.forms.MultipleChoiceField
>> >
>> >
>>
>> That is how I almost replied, but a MultipleChoiceField constrains the
>> submitted values to be within a predefined list of acceptable values.
>> You couldn't use a MultipleChoiceField to collect an arbitrary number
>> of arbitrary strings, it would fail validation.
>>
>> Cheers
>>
>> Tom
>>
>> --
>> 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.
>>
>
> --
> 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.

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



Re: Missing something obvious? Question about forms

2012-01-18 Thread Jeff Heard
Sadly these strings are arbitrary, yes...  I suppose I could subclass
MultipleChoiceField and kill the validator.

On Wed, Jan 18, 2012 at 10:54 AM, Tom Evans wrote:

> On Wed, Jan 18, 2012 at 3:51 PM, Andre Terra  wrote:
> > https://docs.djangoproject.com/en/dev/ref/forms/fields/#choicefield
> >
> https://docs.djangoproject.com/en/dev/ref/forms/fields/#django.forms.MultipleChoiceField
> >
> >
>
> That is how I almost replied, but a MultipleChoiceField constrains the
> submitted values to be within a predefined list of acceptable values.
> You couldn't use a MultipleChoiceField to collect an arbitrary number
> of arbitrary strings, it would fail validation.
>
> Cheers
>
> Tom
>
> --
> 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.
>
>

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



Re: Missing something obvious? Question about forms

2012-01-18 Thread Andre Terra
In this case, I think he can subclass it and override the validate
method[0] and simply allow any choice to pass, right?

Cheers,
AT


[0]
https://code.djangoproject.com/browser/django/trunk/django/forms/fields.py#L780


On Wed, Jan 18, 2012 at 1:54 PM, Tom Evans  wrote:

> On Wed, Jan 18, 2012 at 3:51 PM, Andre Terra  wrote:
> > https://docs.djangoproject.com/en/dev/ref/forms/fields/#choicefield
> >
> https://docs.djangoproject.com/en/dev/ref/forms/fields/#django.forms.MultipleChoiceField
> >
> >
>
> That is how I almost replied, but a MultipleChoiceField constrains the
> submitted values to be within a predefined list of acceptable values.
> You couldn't use a MultipleChoiceField to collect an arbitrary number
> of arbitrary strings, it would fail validation.
>
> Cheers
>
> Tom
>
> --
> 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.
>
>

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



Re: Missing something obvious? Question about forms

2012-01-18 Thread Tom Evans
On Wed, Jan 18, 2012 at 3:51 PM, Andre Terra  wrote:
> https://docs.djangoproject.com/en/dev/ref/forms/fields/#choicefield
> https://docs.djangoproject.com/en/dev/ref/forms/fields/#django.forms.MultipleChoiceField
>
>

That is how I almost replied, but a MultipleChoiceField constrains the
submitted values to be within a predefined list of acceptable values.
You couldn't use a MultipleChoiceField to collect an arbitrary number
of arbitrary strings, it would fail validation.

Cheers

Tom

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



Re: Missing something obvious? Question about forms

2012-01-18 Thread Andre Terra
https://docs.djangoproject.com/en/dev/ref/forms/fields/#choicefield
https://docs.djangoproject.com/en/dev/ref/forms/fields/#django.forms.MultipleChoiceField


Cheers,
AT

On Wed, Jan 18, 2012 at 12:42 PM, Jeff Heard wrote:

> I have a largish API I have to implement from a standard, and it requires
> very complex HTTP processing.  I'd like to use django.forms.Form for that,
> but I can't figure out how to use a form to store a list of parameters.
>
> So while my homemade code might be:
>
> foo = int(request.get('foo', '1'))
> bar = request.getlist(bar)
>
> I can't figure out the corresponding Form class.  What I would *want* is
> something like this:
>
> class MyForm(Form):
>foo = IntegerField()
>bar = ListField(CharField)
>
> but there is no "ListField"  How is this normally handled?
>
> -- Jeff
>
>  --
> 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.
>

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



Missing something obvious? Question about forms

2012-01-18 Thread Jeff Heard
I have a largish API I have to implement from a standard, and it requires
very complex HTTP processing.  I'd like to use django.forms.Form for that,
but I can't figure out how to use a form to store a list of parameters.

So while my homemade code might be:

foo = int(request.get('foo', '1'))
bar = request.getlist(bar)

I can't figure out the corresponding Form class.  What I would *want* is
something like this:

class MyForm(Form):
   foo = IntegerField()
   bar = ListField(CharField)

but there is no "ListField"  How is this normally handled?

-- Jeff

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