1
from django.conf import settings
2
from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured
3
from django.core import validators
4
from django.db import backend, connection
5
from django.db.models.loading import get_apps, get_app, get_models, get_model, register_models
6
from django.db.models.query import Q
7
from django.db.models.manager import Manager
8
from django.db.models.base import Model, AdminOptions
9
from django.db.models.fields import *
10
from django.db.models.fields.related import ForeignKey, OneToOneField, ManyToManyField, ManyToOneRel, ManyToManyRel, OneToOneRel, TABULAR, STACKED
11
from django.db.models import signals
12
from django.utils.functional import curry
13
from django.utils.text import capfirst
16
ADD, CHANGE, BOTH = 1, 2, 3
20
Use in limit_choices_to to compare the field to dates calculated at run time
21
instead of when the model is loaded. For example::
23
... limit_choices_to = {'date__gt' : models.LazyDate(days=-3)} ...
25
which will limit the choices to dates greater than three days ago.
27
def __init__(self, **kwargs):
28
self.delta = datetime.timedelta(**kwargs)
31
return str(self.__get_value__())
34
return "<LazyDate: %s>" % self.delta
36
def __get_value__(self):
37
return datetime.datetime.now() + self.delta
39
def __getattr__(self, attr):
40
return getattr(self.__get_value__(), attr)