Login

Tag "GenericForeignKey"

Snippet List

ContentType template filter

Custom template filter to retrieve a content type of a given model instance. Useful for ModelForms which want to set the content_type field (i.e: GenericForeignKey). ### A usage example: {% load helpers %} {% with instance|content_type as ctype %} <input type="hidden" name="content_type" value="{{ ctype.pk }}"> {% endwith %} Original idea from [this stackoverflow answer] [1] [1]: http://stackoverflow.com/a/12807458/484127

  • template
  • filter
  • tag
  • contenttypes
  • contenttype
  • GenericForeignKey
Read More

1 snippet posted so far.