Tuesday, December 24, 2019

Decisions on selcting ChoiceField

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

No comments:

Post a Comment