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.6-py3-none-any.whl
.
File metadata
- Download URL: edc_list_data-0.1.6-py3-none-any.whl
- Upload date:
- Size: 21.4 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/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc04830b8206c6fcc7600b2863ac1686f663fce86a36873b663cb56b02b2adb1 |
|
MD5 | 3029520e70f5658cb1ada86fe4d9e48d |
|
BLAKE2b-256 | b09b9d83b36eaf9633605319c0fe1debb3c53bce68ef55826bb8154a30072de6 |