Decisions on selcting ChoiceField

23 views
Skip to first unread message

shree hari

unread,
Dec 24, 2019, 8:20:32 AM12/24/19
to Django users
# 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 ?

Nitin Kalmaste

unread,
Dec 24, 2019, 8:33:23 AM12/24/19
to django...@googlegroups.com
You can do request.get[field name]
And make your conditions in views

--
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...@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.
Message has been deleted
Message has been deleted

shree hari

unread,
Dec 24, 2019, 8:58:01 AM12/24/19
to Django users
can you please show me the implementation with respect to my code ?
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages