As a newbie to Django, I am having difficulty making an upload app in Django 1.3. I could not find any up-to-date example/snippets. May someone post a minimal but complete (Model, View, Template) example code to do so?
相关问题
- Django __str__ returned non-string (type NoneType)
- What is the best way to do a search in a large fil
- Django & Amazon SES SMTP. Cannot send email
- Django check user group permissions
- Django restrict pages to certain users
相关文章
- Profiling Django with PyCharm
- Why doesn't Django enforce my unique_together
- MultiValueDictKeyError in Django admin
- What is the correct way to declare and use a FILE
- Django/Heroku: FATAL: too many connections for rol
- Making new files automatically executable?
- Django is sooo slow? errno 32 broken pipe? dcramer
- How to serialize data into indented json [duplicat
I must say I find the documentation at django confusing. Also for the simplest example why are forms being mentioned? The example I got to work in the views.py is :-
The html file looks like the code below, though this example only uploads one file and the code to save the files handles many :-
These examples are not my code, they have been optained from two other examples I found. I am a relative beginner to django so it is very likely I am missing some key point.
Here it may helps you: create a file field in your models.py
For uploading the file(in your admin.py):
and use that field in your template also.
Extending on Henry's example:
You can call this
handle_uploaded_file
function from your view with the uploaded file object. This will save the file with a unique name (prefixed with filename of the original uploaded file) in filesystem and return the full path of saved file. You can save the path in database, and do something with the file later.I faced the similar problem, and solved by django admin site.