Created
March 21, 2019 13:37
-
-
Save perillo/2f828209cea84ff8c753f6f2524119f1 to your computer and use it in GitHub Desktop.
Django: 404 error on multipart/form-date form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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