Skip to main content

Populate list data and other static model data on startup in clinicedc/edc projects

Project description

pypi actions coverage


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 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 migrate.

For example:

class Antibiotic(ListModelMixin, BaseUuidModel):

    class Meta(ListModelMixin.Meta):

An example

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 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

edc-list-data-0.3.17.tar.gz (33.4 kB view hashes)

Uploaded source

Built Distribution

edc_list_data-0.3.17-py3-none-any.whl (34.8 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page