A Django package that adds a global or model based database table prefix
This library should be compatible with the latest Django. For reference, here is a matrix showing the tested compatibility.
| django-model-prefix Version | Django Versions | Python |
|---|---|---|
| 1.1 | 4.2, 5.0, 5.1 | 3.9 - 3.13 |
| 1.0 | 3.2, 4.0, 4.1 | 3.7 - 3.10 |
Install using pip:
pip install django-model-prefixAdd model_prefix to your INSTALLED_APPS list. Make sure it is the first app in the list
INSTALLED_APPS = [
'model_prefix',
...
]The global database table prefix can be configured using the DB_PREFIX setting
DB_PREFIX = "foo_"Optionally a model based prefix can also be defined by extending the models meta class
class Meta:
db_prefix = "bar_"This can be also used in order to disable the global prefix for a specific model
class Meta:
db_prefix = None