Been changing and now have the following code:
Models.py:
*class Document(models.Model):*
* docfile = models.FileField(upload_to='documents/%Y/%m/%d')*
Forms.py:
*class DocumentForm(forms.Form):*
* docfile = forms.FileField()*
Views.py:
*def index(request):*
* if request.method == 'POST':*
* form = DocumentForm(request.POST, request.FILES)*
* if form.is_valid():*
* fnewdoc = Document(docfile = request.FILES['docfile'])*
* newdoc.save()*
* return render_to_response('index.html', {'form': form})*
* else:*
* form = DocumentForm()*
* 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>*
*
*
I when I press submit, it updates the page, but am I not save the image ...
I'm doing something 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.