Opened 13 years ago

Closed 13 years ago

#16851 closed Uncategorized (fixed)

Accessing a forms field value in a template

Reported by: from_a_far@… Owned by: Yaşar Arabacı
Component: Documentation Version: 1.3
Severity: Normal Keywords:
Cc: Yaşar Arabacı Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: yes UI/UX: no

Description

Please could someone put in the documentation that you can access a forms field value in a template by using the following

{{ form.apple.value }}

I only ask because I couldn't find anything on the web about and it's only by trying it that I found it worked

Attachments (2)

form_value.diff (654 bytes ) - added by Yaşar Arabacı 13 years ago.
Added required documentation items
0001-Added-field.value-explanation.patch (827 bytes ) - added by Yaşar Arabacı 13 years ago.
Removed extra remarks about null value

Download all attachments as: .zip

Change History (12)

comment:1 by Carl Meyer, 13 years ago

Triage Stage: UnreviewedAccepted

comment:2 by linovia, 13 years ago

Actually, {{ form.apple.value }} will not be correct if value is None.
{{ form.apple.value|default_if_none:"" }} is a better choice.

comment:3 by Yaşar Arabacı, 13 years ago

Cc: Yaşar Arabacı added
Owner: changed from nobody to Yaşar Arabacı
Status: newassigned

by Yaşar Arabacı, 13 years ago

Attachment: form_value.diff added

Added required documentation items

comment:4 by Yaşar Arabacı, 13 years ago

Has patch: set
Triage Stage: AcceptedReady for checkin

comment:5 by Yaşar Arabacı, 13 years ago

Cc: Yaşar Arabacı removed

comment:6 by Yaşar Arabacı, 13 years ago

Cc: Yaşar Arabacı added

comment:7 by Aymeric Augustin, 13 years ago

Triage Stage: Ready for checkinAccepted

See #16758 - same comment. Also, note that you don't need to add yourself in Cc explicitly. If you've contributed to a ticket (written a comment, uploaded a patch...) Trac will always notify you of updates.

comment:8 by Bas Peschier, 13 years ago

Patch needs improvement: set

Nice and simple addition to the docs, but I do not really agree with the remark about it not being "correct" and one "should" use the default filter: an empty string is not technically None either. Encountering None in templates is something more general and does not need to get mentioned here.

by Yaşar Arabacı, 13 years ago

Removed extra remarks about null value

comment:9 by Christopher Medrela, 13 years ago

Triage Stage: AcceptedReady for checkin

comment:10 by Tim Graham, 13 years ago

Resolution: fixed
Status: assignedclosed

In [17138]:

Fixed #16851 - Added how-to access form field value in template; thanks yasar11732 for the patch.

Note: See TracTickets for help on using tickets.
Back to Top