Tuesday, December 24, 2019

Re: Decisions on selcting ChoiceField

You can do request.get[field name]
And make your conditions in views

On Tue 24 Dec, 2019, 6:50 PM shree hari, <shreehari9481@gmail.com> wrote:
# views.py
def price_choices(request):
    if request.method == "GET":
        context = {} 
        context['form'] = pricechoice() 
        return render( request, "template_form.html", context)

# forms.py
price_CHOICES =( 
    ("1", "25"), 
    ("2", "50"), 
    ("3", "100"), 
    ("4", "200"), 

class pricechoice(forms.Form): 
    pricechoice = forms.ChoiceField(choices = price_CHOICES,  widget=forms.RadioSelect()) 

# template
<form method = "GET"> 
    {{ form }}
</form>


If choice 25 is selected, i want it make a calculation.
How can i do it ?

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0bf89c8f-e6e9-4a45-a5fc-c8fcbbd3c125%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKroR%2B1deSQEqS%2BQjZY5ykoK-cLnUd4s%3DY3SCeUyVBPSPTvZaw%40mail.gmail.com.

No comments:

Post a Comment