Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Python HTML JavaScript

This branch is 1 commit ahead, 354 commits behind master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
doc
fusionbox
.gitignore
LICENSE
MANIFEST
README.md
intro.rst
setup.py

README.md

django-fusionbox

Useful tools for Django development.

GenericTemplateFinderMiddleware

This middleware will automatically find a template based on the request url and render it. Useful during early design stages to allow quick static pages to use the template system.

Add fusionbox.middleware.GenericTemplateFinderMiddleware to your MIDDLEWARE_CLASSES to activate.

Usage examples

  • / renders index.html
  • /foo/ renders /foo.html OR /foo/index.html OR /foo
  • This works for any directory depth

Behavior

Behaviors are a DRY way of re-using common fields and methods on models. Behaviors function seamlessly through python inheritance and are fully configurable. Behaviors also support multi-inheritance so adding multiple behaviors to a single model is as easy as inheriting from each behavior you wish to add.

Standard Usage

from fusionbox.behaviors import TimeStampable

class Foo(TimeStampable):
    pass

This will add the fields created_at and updated_at to your Foo model.

Just as their names suggest, the model will have the following fields.

  • created_at => DateTimeField(auto_now_add=True)
  • updated_at => DateTimeField(auto_now=True)

Custom Configuration Usage

from fusionbox.behaviors import TimeStampable

class Foo(TimeStampable):
    class TimeStampable:
        created_at = "creation_date"
        updated_at = "date_updated"

This will add the same fields as in the standard usage, but the fields will instead be named creation_date and date_updated respectively

fusionbox_tags

Put {% load fusionbox_tags %} in your template to use these.

{% higlight_here %}

This template tag will parse all anchor tags between higlight_here and endhighlight and add a class to the ones that are considered 'parents' of the current page's url. It takes an optional class name as an argument, defaulting to here.

Usage examples

    {% highlight_here %}
        <a href="/" class="home">/</a>
        <a href="/blog/">blog</a>
    {% endhighlight %}


    {% highlight_here big red %}
        <a href="/">/</a>
        <a href="/blog/">blog</a>
    {% endhighlight %}
Something went wrong with that request. Please try again.