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.
The list models are populated using a post_migrate signal. Once everything is configured or after changes are made, you need to run python manage.py migrate.
For example:
class Antibiotic(ListModelMixin, BaseUuidModel):
class Meta(ListModelMixin.Meta):
pass
An example list_data.py:
from edc_constants.constants import OTHER
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')
],
}
- Now run:
>>> python manage.py migrate
The list data will be populated in the order in which the list items are declared.
See also call to site_list_data.autodiscover and site_list_data.load_data called in edc_list_data.apps.AppConfig using a post_migrate signal.
Metadata
Release files for edc-list-data 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| edc_list_data-1.0.0.tar.gz | 35.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| edc_list_data-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 72.9 kB
Release files / edc_list_data-1.0.0.tar.gz
| Download URL | edc_list_data-1.0.0.tar.gz |
|---|---|
| Size | 35.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
77dc3b3e208f16faaf7111a739297aa5dcddf6645bec4a0b2326544ae6b5dd26
|
|
BLAKE2b-256 checksum How to use checksums |
dc6d6845bfa62f84105c0957c6dcc1c6824ac7d49531566bd2cf408c98b28d99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.4
|
Release files / edc_list_data-1.0.0-py3-none-any.whl
| Download URL | edc_list_data-1.0.0-py3-none-any.whl |
|---|---|
| Size | 37.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
24ee3dc402177f3b5221b7bbf2fccbbcf787bd9b8ee263fd70ee9723819c3857
|
|
BLAKE2b-256 checksum How to use checksums |
be1efe3464b8908a51b41e114a61eecaa32ff60b3275f6089791f9154146b88b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.4
|