1. Jannis Leidel
  2. django-licenses

Wiki

Clone wiki

django-licenses / Examples

Examples

Simple examples how to use django-licenses

Simple releations

from django.db import models
from licenses.fields import LicenseField

class Blog(models.Model):
	title = models.CharField(max_length = 100)
	content = models.TextField()
	license = LicenseField()
	# or with some paramters:
	license = LicenseField(related_name = 'blogs', required = False)

Template

Get the object via the blog

{{ some_blog.license }}
{{ some_blog.license.description }}

Get without the view

{% load licensing %}

{# user the abbreviation: #}
{% get_license_by_abbr "CC-BY-SA" as license %}
{# or via slug: #}
{% get_license_by_slug "cc-by-sa" as license %}

{{ license }}
{{ license.description }}

Filters

{% load licensing %}

{{ license|license_link }}
{{ license|license_short_link }}
{{ license|license_logo }}

Updated