Login

Tag "file"

Snippet List

upload handler decorators

In an admin custom view I had the requirement to modify the upload handlers. However, the @staff_member_required locked the Files upload handlers as it uses the request.POST - see [Ticket 7654](http://code.djangoproject.com/ticket/7654). These decorators can be used before other decorators to allow setting of the upload handlers. Usage example: @upload_handlers_insert(0, QuotaUploadHandler) @staff_member_required def upload(request): pass

  • admin
  • decorator
  • file
  • uploadhandler
Read More

Render to file

As a demo, I was asked to write a `render_to_file()` function to load a template and render it to a file. Turns out it's amazingly easy, and I think it's a neat trick to have in your bag of tools.

  • template
  • render
  • file
Read More

Ajax progress bar

This snippet is an example of an ajax progress bar (using jquery) that you might use in conjunction with <http://www.djangosnippets.org/snippets/678/>. 1. Generates a uuid and adds X-Progress-ID to the forms action url. 2. Adds the progress bar to the page. (you'll have to add some css styling for this) 3. Makes period ajax requests to update the progress bar.

  • ajax
  • javascript
  • upload
  • file
  • progress
Read More

Log errors to a file

This is another example use of the [exception middleware](http://www.djangosnippets.org/snippets/638/). It shows how to log exceptions to a file. Someone wanted to do this to avoid DOS-ing the email server in case of a silly error. (untested.)

  • middleware
  • log
  • error
  • exception
  • file
Read More

MultiFileWidget

This is a multi file upload widget. That does not require adding multiple file input fields. It requires jQuery.MultiUpload (http://www.fyneworks.com/jquery/multiple-file-upload/)

  • newforms
  • upload
  • multi-file-upload
  • file
Read More

20 snippets posted so far.