I'm trying to make a simple uplaod picture but I'm not getting. I'm doing
the following way:
*Models.py:*
*class TestUpload(models.Model):*
* model_pic = models.ImageField(upload_to='Temp/', blank=True,
null=True)*
*
*
*Forms.py:*
class TestUploadForm(forms.Form):
image = forms.ImageField()
Views.py:
def index(request):
if request.method == 'POST':
form = TestUploadForm(request.POST, request.FILES)
if form.is_valid():
form.save()
return render_to_response('index.html', {'form': form})
else:
form = TestUploadForm()
return render_to_response('index.html', {'form': form},
context_instance=RequestContext(request)
)
index.html:
<!doctype html>
<html>
<head>
<title>{% block title %}{% endblock %}</title>
</head>
<body>
<marquee>Teste!</marquee>
{% block content %}{% endblock %}
<h1>Inserir</h1>
<form action="" method="post" enctype="multipart/form-data">{%
csrf_token %}
<p>
<input id="id_image" type="file" class="" name="image">
</p>
<input type="submit" value="Submit" id="Save" />
</form>
</body>
</html>
But it is not working ... does anyone know what I'm doing wrong?
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.