Ok now i have written my view,py
def payhistory(request):
paynum=selection.objects.all()
num=request.POST.get('dropdown')
if request.method=='GET':
form=paynumberform()
else:
select=selection.objects.get(num=num)
#do someting
return render(request,'displaypayhistory.html',locals())
return render(request,'payhistory.html',{'form':form,'paynum':paynum})
and my template 'payhistory.html
<form action="{%url 'payhistory'%}" method ="POST">{%csrf_token%}
<table>
<tr><td>Pay Number:</td>
<td>
<select name='dropdown'>
{%for paynum in paynum%}
<option value="{{paynum.num}}">{{paynum.num}}</option>
{%endfor%}
</select>
</td>
<td><input type="submit" value="Process"/></td>
</tr>
</table>
</form>
i manage to load the form, but the drop down list elements are not showing.
cheers,
On Fri, Feb 16, 2018 at 11:00 AM, sum abiut <[email protected]> wrote:
> I have a model.py
> class selection(models.Model):
> select=(
> (A','A'),
> ('B','B'),
> ('C','C'),
>
>
> )
>
> options=models.CharField(max_length=7,choices=select)
>
>
> and form.py
>
> class order(forms.ModelForm):
> class Meta:
> model=selection
> fields=('Pay_options,)
>
>
> I want to write a view.py that check the form for the choice that is
> selected but i don't know how to get started. for example if a user select
> option A, i want to perform some query. I want to know how to check for the
> options that are selected before i can performing a query. Appreciate any
> assistances.
>
> cheers,
>
--
--
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 [email protected].
To post to this group, send email to [email protected].
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/CAPCf-y74TkxU925m6V3hqh6c0U8NmaKjoKt4fwXADOuXFVPtqQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.