app/django/db/models/__init__.py
author Pawel Solyga <Pawel.Solyga@gmail.com>
Sun, 16 Nov 2008 15:26:40 +0000
changeset 485 2865922ea06a
parent 323 ff1a9aa48cfd
permissions -rw-r--r--
Change id to account in base.html template (without this change we couldn't signout using top right links and also couldn't display currently logged in account information on the left side of links). This patch is related to commit in revision r1022. http://code.google.com/p/soc/source/detail?r=1022 Patch by: Pawel Solyga

from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured
from django.db import connection
from django.db.models.loading import get_apps, get_app, get_models, get_model, register_models
from django.db.models.query import Q
from django.db.models.manager import Manager
from django.db.models.base import Model
from django.db.models.fields import *
from django.db.models.fields.subclassing import SubfieldBase
from django.db.models.fields.files import FileField, ImageField
from django.db.models.fields.related import ForeignKey, OneToOneField, ManyToManyField, ManyToOneRel, ManyToManyRel, OneToOneRel
from django.db.models import signals

# Admin stages.
ADD, CHANGE, BOTH = 1, 2, 3

def permalink(func):
    """
    Decorator that calls urlresolvers.reverse() to return a URL using
    parameters returned by the decorated function "func".

    "func" should be a function that returns a tuple in one of the
    following formats:
        (viewname, viewargs)
        (viewname, viewargs, viewkwargs)
    """
    from django.core.urlresolvers import reverse
    def inner(*args, **kwargs):
        bits = func(*args, **kwargs)
        return reverse(bits[0], None, *bits[1:3])
    return inner