Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#19610 closed Cleanup/optimization (fixed)

Include enctype in example forms

Reported by: will@… Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

On this page:
https://docs.djangoproject.com/en/dev/topics/forms/

It took me ages to figure out the reason files weren't uploading was because I'd left out enctype="multipart/form-data" from my <form> tag in my template.
I suggest changing the template examples from:

<form action="/contact/" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit" />
</form>

to:

<form action="/contact/" method="post" enctype="multipart/form-data">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit" />
</form>

Attachments (1)

19610.diff (1.4 KB) - added by timo 3 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 3 years ago by charettes

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

What about using the is_multipart property in the documentation?

<form action="/contact/" method="post"{% if form.is_multipart %} enctype="multipart/form-data"{% endif %}>{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit" />
</form>

comment:2 Changed 3 years ago by timo

  • Easy pickings set
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Cleanup/optimization

+1

Changed 3 years ago by timo

comment:3 Changed 3 years ago by timo

  • Has patch set

comment:4 Changed 3 years ago by claudep

  • Triage Stage changed from Accepted to Ready for checkin

comment:5 Changed 3 years ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 0de2645c00c2330060c9889c71afd3a528ed7a3a:

Fixed #19610 - Added enctype note to forms topics doc.

Thanks will@ for the suggestion.

comment:6 Changed 3 years ago by Tim Graham <timograham@…>

In 2e6b0c5ca7265b3cee2ff68a9ef5d1865afb9a49:

[1.5.x] Fixed #19610 - Added enctype note to forms topics doc.

Thanks will@ for the suggestion.

Backport of 0de2645c00 from master

comment:7 Changed 3 years ago by Tim Graham <timograham@…>

In 2e6b0c5ca7265b3cee2ff68a9ef5d1865afb9a49:

[1.5.x] Fixed #19610 - Added enctype note to forms topics doc.

Thanks will@ for the suggestion.

Backport of 0de2645c00 from master

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