Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A set of tools to execute parts of your code only if a specified application is installed.
Python
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
oida
LICENCE
README
setup.py

README

==================================================
django-oida - [O]nly [I]f [D]ependency [A]vailable
==================================================

Oida provides you with a set of tools to execute parts of your code only
if a specified application is installed.

If your "django site" is powered by a core set of applications and you
add or remove several others to bundle up editions of it, you might end
up commenting and uncommenting lines in a shared code base. Although it
might be a good idea to keep your code as decoupled as possible, some 
parts are tricky: Think of the root URL configuration or enhanced admin 
views for models (If you have better solutions for that, please drop me
a note).


Templatetags
============
if_app: An if statement that validates to True if an app is loaded.

Example (the else tag is optional):
{% load apps %}
...
{% if_app "tagging" %}
    <p>tagging is installed</p>
{% else %}
    <p>tagging is not installed</p>
{% endif_app %}


Method
======
Let's assume that you want to add a reverse generic relation showing
all tagged item objects for a Model, but only if the tagging app is 
installed:

from oida import is_app_installed
...
if is_app_installed('tagging'):
    tagged_items = generic.GenericRelation('tagging.TaggedItem')
    # If you really want to do that, consider using 
    # tagging.fields.TagField


Decorator
=========
If you have a method, you can decorate it with the
if_app_installed decorator.

from oida.decorators import if_app
...
@if_app('tagging')
def my_method():
    print 'yay, tagging is installed'
Something went wrong with that request. Please try again.