Skip to content

Instantly share code, notes, and snippets.

@perillo
Created March 21, 2019 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perillo/2f828209cea84ff8c753f6f2524119f1 to your computer and use it in GitHub Desktop.
Save perillo/2f828209cea84ff8c753f6f2524119f1 to your computer and use it in GitHub Desktop.
Django: 404 error on multipart/form-date form
from django import forms
from django import http
from django import template
def bug(request):
tmpl = template.Template("""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bug</title>
</head>
<body>
<form action="." method="post" enctype="multipart/form-data">
{#<input type="file" name="{{ form.name }}">#}
{{ form }}
<input type="submit">
</form>
</body>
</html>
""")
class Bug(forms.Form):
file = forms.FileField(required=False)
form = Bug()
ctx = template.Context({'form': form})
content = tmpl.render(ctx)
return http.HttpResponse(content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment