Populate list data and other static model data on startup
Project description
edc-list-data
Populate list data and other static model data on Django startup.
To install add edc_list_data.apps.AppConfig to your INSTALLED_APPS, then create a list_data.py in the root of your app.
Most commonly used to populate M2M data known here as list_data. M2M field models should use the ListModelMixin.
For example:
class Antibiotic(ListModelMixin, BaseUuidModel):
class Meta(ListModelMixin.Meta):
pass
An example list_data.py:
from edc_constants.constants import OTHER
from edc_list_data import PreloadData
list_data = {
'my_lists_app.antibiotic': [
('flucloxacillin', 'Flucloxacillin'),
('gentamicin', 'Gentamicin'),
('ceftriaxone', 'Ceftriaxone'),
('amoxicillin_ampicillin', 'Amoxicillin/Ampicillin'),
('doxycycline', 'Doxycycline'),
('erythromycin', 'Erythromycin'),
('ciprofloxacin', 'Ciprofloxacin'),
(OTHER, 'Other, specify')
],
}
preload_data = PreloadData(list_data=list_data)
PreloadData will persist the list data in model Antibiotic and maintain the order in which the list items are declared.
See also call to site_list_data.autodiscover called in edc_list_data.apps.AppConfig.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file edc_list_data-0.1.13-py3-none-any.whl
.
File metadata
- Download URL: edc_list_data-0.1.13-py3-none-any.whl
- Upload date:
- Size: 21.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5a7b3b82fa9a0697d0fc279934816ba7caea1a450de3a51fac58f66690944d2 |
|
MD5 | 56db399b7a973ab357a4eb5864b7a756 |
|
BLAKE2b-256 | a557968ea91fb6005845b1589fedc70f87e253e2d2c6053f5e74a44e5242a89c |