Skip to content

Configuration

rvinzent edited this page May 17, 2020 · 1 revision

dynamic_models has a few configuration options available. Set these under a DYNAMIC_MODELS object in the Django settings.

# settings.py

INSTALLED_APPS = [
    ...
    'dynamic_models',
    ...
]

DYNAMIC_MODELS = {
    ...configuration options...
}
DEFAULT_CHARFIELD_MAX_LENGTH

The default max_length value to use when generating CharField. Defaults to 255

CACHE_TIMEOUT

Set how long in seconds to keep Django models in the cache. Cache hits should result in less queries to the database.

USE_APP_LABEL

Register generated dynamic models under this app label. Defaults to dynamic_models

CACHE_KEY_PREFIX

Use this prefix for cached model entries. Defaults to dynamic_models_.

DEFAULT_FIELDS

A dictionary of field names to Field instances that can be used to inject a common set of fields into all generated dynamic models. Defaults to {}

DEFAULT_FIELDS = {
    'common_field': fields.IntegerField(),
}
Clone this wiki locally