Jay Parlar wrote:
>However, I need to use this with my own view, which currently looks as follows:
>
>def upload_file(request):
> manipulator = FirmwareUpload.AddManipulator()
> if request.POST:
> new_data = request.POST.copy()
> new_data['firmware'] = _save_file(request.FILES['firmware_file'])
> errors = manipulator.get_validation_errors(new_data)
> if errors:
> _nuke_file(request.FILES['firmware_file'])
> print errors
> return HttpResponseRedirect("error/")
> else:
> manipulator.do_html2python(new_data)
> manipulator.save(new_data)
>
> return HttpResponseRedirect("success/")
>
>
Instead of saving your file manually use Django's helper method:
obj = manipulator.save(new_data)
info = request.FILES['firmware_file']
obj.save_firmware_file_file(info['filename'], info['content'])
This not only fills date values but also resolves filename conflicts.
http://www.djangoproject.com/documentation/db_api/#save-foo-file-filename-raw-contents
The actual filename may change during this save_*_file so to get real
(and full) filename you use obj.get_firmware_file_filename().
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---