Metadata-Version: 1.1
Name: django-leaf
Version: 2.1.0
Summary: Render and serve django templates based on URL.
Home-page: UNKNOWN
Author: Ryan Senkbeil
Author-email: ryan.senkbeil@gsdesign.com
License: UNKNOWN
Description: # django-leaf
        
        > Render django templates based on URL path.
        
        [![Build Status](https://img.shields.io/travis/gsmke/django-leaf/master.svg?style=flat)](https://travis-ci.org/gsmke/django-leaf)
        [![Latest Version](https://img.shields.io/pypi/v/django-leaf.svg?style=flat)](https://pypi.python.org/pypi/django-leaf/)
        
        ## Quick start
        
        1. Install the package from pypi:
        
            ```bash
            pip install django-leaf
            ```
        
        2. Add "leaf" and "mptt" to your INSTALLED_APPS:
        
            ```python
            INSTALLED_APPS = (
                ...
                'leaf',
                'mptt',
            )
            ```
        
        3. Add leaf urls to *the end* of your urlpatterns:
        
            ```python
            url(r'^', include('leaf.urls')),
            ```
        
        ## Usage
        
        django-leaf can be used to render both "static" and database-backed templates.
        
        ### Static Templates
        
        If you want to render a template when a user goes to `/example/url/`, create one of the following files:
        
        1. example/url.html
        2. example/url/index.html
        3. pages/example/url.html
        4. pages/example/url/index.html
        
        ### Database Backed Templates
        
        After installing django-leaf, the admin interface will have a new section called `Pages` where you'll be able to create your page hierarchy.
        
        To define your own page model, you need to extend from `leaf.models.Page`.
        There are a few fields available for customization:
        
        1. **identifier**: A unique identifier for your model. This will be used to associate page nodes with your page implementation. If you don't provide an `identifier`, one will be provided for you.
        2. **template**: The template to render.
        3. **admin_page_inline**: The admin class to use when rendering the template fields inline. This defaults to the default ``admin.StackedInline``.
        4. **admin_inlines**: A list of other inlines to add to the admin.
        
        Here's an example for creating a page with translations provided by [django-parler](https://github.com/edoburu/django-parler):
        
        ```python
        # admin.py
        from parler.admin import TranslatableStackedInline
        
        
        class AboutPageInline(TranslatableStackedInline):
            pass
        
        # models.py
        from django.db import models
        from leaf.models import Page
        from parler.models import TranslatableModel, TranslatedFields
        
        from .admin import AboutPageInline
        
        
        class AboutPage(Page, TranslatableModel):
            admin_page_inline = AboutPageInline
            identifier = 'about-page'
            template = "about.html"
        
            translations = TranslatedFields(
                headline=models.CharField(max_length=255),
                copy=models.TextField(blank=True)
            )
        
            def __unicode__(self):
                return self.headline
        ```
        
        When rendering the template, all of the model fields will be available on the ``page`` context variable:
        
        ```django
        {{ page.headline }}
        {{ page.copy }}
        ```
        
        #### Home Page
        
        The root page can be added to django-leaf by adding a new page with `slug=home` and `parent=None`. All pages added under that will be added without the ``home`` part in the path.
        
        # TODO
        
        1. Better documentation.
        2. More configuration options.
        
Platform: any
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Internet :: WWW/HTTP
