Yes, I use Form. Here's it's contents:
from django import forms
from .widgets import ChainedSelectWidget
from .models import Child
class SponsorForm(forms.Form):
child = forms.IntegerField()
class FilterForm(forms.Form):
gender = forms.ChoiceField(choices=[(x, x) for x in ('-', 'MALE',
'FEMALE')], required=False)
age = forms.ChoiceField(choices=[(x, x) for x in range(1, 18)],
required=False)
#orphaned = forms.BooleanField(initial=False,required=False)
#extreme_need = forms.BooleanField(initial=False,required=False)
handicapped = forms.ChoiceField(choices=[(x, x) for x in ('---',
'Mental', 'Physcal')], required=False)
def __init__(self, *args, **kwargs):
super(FilterForm, self).__init__(*args, **kwargs)
if 0 == len(self.data):
self.fields['age'].queryset = Child.objects.none()
# assign a widget to second select field
self.fields['age'].widget = ChainedSelectWidget(
parent_name='gender', # the name of parent field
app_name='sponsorship',# the name of model's
application
model_name='child', # the name of a model with the
method
method_name='get_children', # the name of queryset method
)
It is for finding a child who may or may not have one of two types of
handicaps.
-Eileen
On Friday, January 19, 2018 at 9:54:15 PM UTC-5, Costja Covtushenko wrote:
>
> Hi Eileen,
>
> Can you please elaborate a little bit?
> Do you use Form? Can you provide its code?
>
> Also sorry but it is not clear what are you trying to achieve with those
> value?
> Is it for searching data in DB?
>
> Regards,
> Constantine C.
>
> On Jan 19, 2018, at 5:08 PM, eil...@themaii.org wrote:
>
> handicapped
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/f7cddedd-48b3-4542-8b34-acafb183b02d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.