How you store the files is independent of whether or not they come via AJAX. Your view will still need to process the multipart form data, and store it in your DB and server filesystem, like any other uploaded file in Django.
As far as the model goes, how about something like this?
class TemporaryFileWrapper(models.Model):
"""
Holds an arbitrary file and notes when it was last accessed
"""
uploaded_file = models.FileField(upload_to="/foo/bar/baz/")
uploading_user = models.ForeignKey(User)
uploaded = models.DateTimeField(blank=True, null=True, auto_now_add=True)
last_accessed = models.DateTimeField(blank=True, null=True,
auto_now_add=False, auto_now=False)
def read_file(record_read=True):
#...some code here to read the uploaded_file
if record_read:
self.last_accessed = datetime.datetime.now()
self.save()
For basic file upload handling see the official documentation, but where the example has the handle_uploaded_file() method, you need some code that creates a TemporaryFileWrapper object, something like this, depending on your needs:
....
form = ProviderSelfEditForm(request.POST, request.FILES) #this is where you bind files and postdata to the form from the HTTP request
if form.is_valid():
temp_file_wrapper = TemporaryFileWrapper()
temp_file_wrapper.uploaded_file =
form.cleaned_data['name_of_file_field_in_your_form)
temp_file_wrapper.uploading_user = request.user #needs an authenticated user
temp_file_wrapper.save()
return HttpResponseRedirect('/success/url/')