Login

Snippets by king

Snippet List

Load template from specific app

You can use this template loader if you want to use template specifically from one app. Useful mainly in overriding admin templates - just make your own `admin/change_form.html` and have it extend `admin:admin/change_form.html` withou creating any symlinking or copying django admin's templates to alternate location. Part of the [ella project](http://www.ellaproject.cz/).

  • template
  • loader
  • app
Read More

EditInline for GenericForeignKey

A simple InlineModelAdmin class that enables you to edit models that are bound by the instance via a generic foreign key (`content_type`, `object_id` pair) Use like: class PlacementInlineOptions( generic.GenericTabularInline ): model = Placement extra = 2 ct_field_name = 'target_ct' id_field_name = 'target_id' Can be also found at #4667

  • admin
  • foreignkey
  • generic
  • edit-inline
Read More

Wizard class

Wizard class - subclass this, supply a done() method and then you can use `MyWizard( [list, of, newforms, classes])` as a view function. see [#3218](http://code.djangoproject.com/ticket/3218)

  • newforms
  • form
Read More

Create OpenOffice documents

This view will enable you to generate OpenOffice documents from templates written in OpenOffice 2.x Just make sure that there is no OO tag in between your code (no change in formatting etc.). content.xml is a valid XML file, so you can do some preprocessing using xml.dom.minidom. I would also recommend caching (just save the zip file without content.xml and content.xml on its own).

  • print
  • odf
  • office
Read More

king has posted 4 snippets.