Login

Snippets by jimmylam

Snippet List

A form field for valdating PDF and Microsoft Word document

This is form field for PDF or Microsoft Word Document (both .doc and .docx) It will validate the file uploaded as a valid PDF and MS Word Document. It extends a forms.FileField, so you can put all the arguments relevant to FileField. IMPORTANT NOTE: The method of validation is actually run thru *nix OS shell command 'file', therefore, 1. only *nix system can use this class. 2. The file uploaded must be saved on disk, meaning you need to set your upload handler to use TempoaryFileUploadHandler Only. # (i.e. put this in your settings.py) FILE_UPLOAD_HANDLERS = ( "django.core.files.uploadhandler.TemporaryFileUploadHandler", )

  • pdf
  • microsoft-word-document
  • form-field
Read More

Add a print link to the admin to print individual record

This is a view that can be used to add a print button (link) in the admin change form for an individual record. Pretty simple to use. A nice enhancement to it is to be able to pull the model field name tie with the field value, something like making {{ object.as_dl }} available to the template. PS: The code is a modification from the django.views.generic.list_detail.object_detail

  • print
  • admin
  • record
Read More

jimmylam has posted 2 snippets.