I want to fetch the value of radio field for updation but it only doesn't fetch even i use condition and value does comes but doesn't checked

74 views
Skip to first unread message

Abhinandan K

unread,
Aug 22, 2022, 2:57:46 AM8/22/22
to django...@googlegroups.com
<label>Email</label>
<input type="email" name="email" value={{datas.email}}>
{% with val_gen=datas.gender%}
{{val_gen}}
<label>gender:</label><br></br>

<input type="radio" name="gender" value="Male"{% if val_gen == Male %} checked{% endif %} >Male</input>
<input type="radio" name="gender" value="Female"{% if val_gen == Female %} checked{% endif %}>Female</input><br><br>
<input type="submit" value="Update">
{% endwith %}
</form>
Screenshot 2022-08-22 at 12.22.54 PM.png

Abdul Qoyyuum

unread,
Aug 22, 2022, 4:34:50 AM8/22/22
to django...@googlegroups.com
You'll need to use a RadioSelect widget. See example in the link as follows: https://docs.djangoproject.com/en/4.0/ref/forms/widgets/#django.forms.RadioSelect

--
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/CAA6_Mp44RQjMeWfVW82vvT2-GLrv5Jpu2nb_6edWON_3sgXQwQ%40mail.gmail.com.


--
Abdul Qoyyuum Bin Haji Abdul Kadir

Ryan Nowakowski

unread,
Aug 23, 2022, 9:31:59 AM8/23/22
to django...@googlegroups.com
On Mon, Aug 22, 2022 at 12:26:40PM +0530, Abhinandan K wrote:
> <input type="radio" name="gender" value="Male"{% if val_gen == Male %}
> checked{% endif %} >Male</input>
> <input type="radio" name="gender" value="Female"{% if val_gen == Female %}
> checked{% endif %}>Female</input><br><br>
> <input type="submit" value="Update">

Do you need quotes around Male/Female like this?

Ammar Mohammed

unread,
Aug 23, 2022, 9:49:55 AM8/23/22
to django...@googlegroups.com

<label>Email</label>


<input type="email" name="email" value={{datas.email}}>


{% with val_gen=datas.gender%}


{{val_gen}}


<label>gender:</label><br></br>

<input type="radio" name="gender" value="Male" {% if val_gen == "Male" %} checked{% endif %} >Male</input> <br>


<input type="radio" name="gender" value="Female" {% if val_gen == "Female" %} checked{% endif %}>Female</input> <br><br>


<input type="submit" value="Update">


{% endwith %}


</form>


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

Mihir Patel

unread,
Aug 24, 2022, 12:07:11 PM8/24/22
to django...@googlegroups.com
i dont have much idea but try to do with True Or False value bcz maybe it returns boolean value.

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

Godswill King Trace

unread,
Aug 31, 2022, 9:14:11 AM8/31/22
to django...@googlegroups.com

subin

unread,
Sep 1, 2022, 2:58:44 PM9/1/22
to django...@googlegroups.com
Thank you for contacting through our website. We’ll follow up with you soon

Reply all
Reply to author
Forward
0 new messages