from django.core import formfields, validators from django.core import db from django.core.exceptions import ObjectDoesNotExist from django.conf import settings import copy, datetime, os, re, sys, types # The values to use for "blank" in SelectFields. Will be appended to the start of most "choices" lists. BLANK_CHOICE_DASH = [("", "---------")] BLANK_CHOICE_NONE = [("", "None")] # Admin stages. ADD, CHANGE, BOTH = 1, 2, 3 # Values for Relation.edit_inline_type. TABULAR, STACKED = 1, 2 # Values for filter_interface. HORIZONTAL, VERTICAL = 1, 2 # Random entropy string used by "default" param. NOT_PROVIDED = 'oijpwojefiojpanv' # Size of each "chunk" for get_iterator calls. # Larger values are slightly faster at the expense of more storage space. GET_ITERATOR_CHUNK_SIZE = 100 # Prefix (in python path style) to location of models. MODEL_PREFIX = 'django.models' # Methods on models with the following prefix will be removed and # converted to module-level functions. MODEL_FUNCTIONS_PREFIX = '_module_' # Methods on models with the following prefix will be removed and # converted to manipulator methods. MANIPULATOR_FUNCTIONS_PREFIX = '_manipulator_' LOOKUP_SEPARATOR = '__' RECURSIVE_RELATIONSHIP_CONSTANT = 'self' #################### # HELPER FUNCTIONS # #################### # capitalizes first letter of string capfirst = lambda x: x and x[0].upper() + x[1:] # prepares a value for use in a LIKE query prep_for_like_query = lambda x: str(x).replace("%", "\%").replace("_", "\_") # returns the