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
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for edc_list_data-0.1.19-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad5359bc01cb26f607544a6aa8a7e85590831fd505c0c9220231737a3963ecde |
|
MD5 | 8a55bef9c56b398dd512440678571dee |
|
BLAKE2b-256 | 504030f6c9ba4de99d2b5b55388bf03152d7410ba29a442709d9eab292d2baff |