Populate list data and other static model data on startup in clinicedc/edc projects
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.
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.
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 Distribution
Built Distribution
File details
Details for the file edc-list-data-0.3.24.tar.gz
.
File metadata
- Download URL: edc-list-data-0.3.24.tar.gz
- Upload date:
- Size: 34.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d91dbe3af3b4d46ab98bd1e10afdc428601ffe4e9ef560b4766e1f3de7ccd4c8 |
|
MD5 | eaf9133d5ccefb5f2183ab82bb293489 |
|
BLAKE2b-256 | 206eedcb04bc4066692ee36e8db860d8c396efac27cbb5c81857d8ffad64b0fe |
File details
Details for the file edc_list_data-0.3.24-py3-none-any.whl
.
File metadata
- Download URL: edc_list_data-0.3.24-py3-none-any.whl
- Upload date:
- Size: 36.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bda2a31748dba9a405e6731c0429afafbd5871ea452c6f72542eaa42679f39f |
|
MD5 | c7cfda6d0f8a67d07ddb18351aa793b3 |
|
BLAKE2b-256 | 5d0ee180034cc46e26cc63392038a8a26171b1e6ba7deac7533bc33d6ba04723 |