sjtirtha wrote: > But what I understand from the documentation is uploading and saving are two > different processes. How can I trigger the saving then? >
First, certainly, when a file is uploaded from a client, django puts it somewhere *temporary* initially. You may have conceptualised that as "saving", but remember it's only an initial temporary location - either in a pseudofile in RAM or on disk (settings.FILE_UPLOAD_TEMP_DIR), with a size based cutoff (settings.FILE_UPLOAD_MAX_MEMORY_SIZE, 2.5MByte by default) to decide which. Either way, this temporary UploadedFile "looks like" a file to python code, and you can see it in request.FILES in the view and treat it like a (temporary!) file. If you just used a plain Form with a forms.FileField, you're pretty much on your own now. Do what you want with the UploadedFile, very probably save it off somewhere more permanent of your choosing. That's what the page you were looking at covers. /However/ there's _extra_ support for "files as model fields" in django's ORM layer (models) - for models.FileField, when you save a model instance, a filename reference is stored in the DB while the file is stored on the filesystem in a more permanent predefined location (under MEDIA_ROOT to facilitate serving the file back out statically). So if you've used a models.FileField on a _model_ and a ModelForm generated from it, you can use .save() . That will save the UploadedFile to your defined permanent location for model files. http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_to -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.