Skip to main content

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

Project description

pypi actions coverage

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


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-1.0.0.tar.gz (35.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

edc_list_data-1.0.0-py3-none-any.whl (37.9 kB view details)

Uploaded Python 3

File details

Details for the file edc_list_data-1.0.0.tar.gz.

File metadata

  • Download URL: edc_list_data-1.0.0.tar.gz
  • Upload date:
  • Size: 35.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for edc_list_data-1.0.0.tar.gz
Algorithm Hash digest
SHA256 77dc3b3e208f16faaf7111a739297aa5dcddf6645bec4a0b2326544ae6b5dd26
MD5 6e7d6371bea033d925e95cf3f56afb82
BLAKE2b-256 dc6d6845bfa62f84105c0957c6dcc1c6824ac7d49531566bd2cf408c98b28d99

See more details on using hashes here.

File details

Details for the file edc_list_data-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: edc_list_data-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 37.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for edc_list_data-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 24ee3dc402177f3b5221b7bbf2fccbbcf787bd9b8ee263fd70ee9723819c3857
MD5 b58cd84a280b1fd725bac16c25974d63
BLAKE2b-256 be1efe3464b8908a51b41e114a61eecaa32ff60b3275f6089791f9154146b88b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page