Commits

Bela Hausmann committed 4c5b7d5

Created wiki examples page

Comments (0)

Files changed (1)

+== Examples ==
+
+Simple examples how to use django-licenses
+
+=== Simple releations ===
+
+{{{
+#!python
+
+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
+
+{{{
+#!html+django
+
+{{ some_blog.license }}
+{{ some_blog.license.description }}
+}}}
+
+Get without the view
+
+{{{
+#!html+django
+
+{% 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
+
+{{{
+#!html+django
+
+{% load licensing %}
+
+{{ license|license_link }}
+{{ license|license_short_link }}
+{{ license|license_logo }}
+}}}