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

Uploaded Source

Built Distribution

edc_list_data-0.3.16-py3-none-any.whl (34.8 kB view details)

Uploaded Python 3

File details

Details for the file edc-list-data-0.3.16.tar.gz.

File metadata

  • Download URL: edc-list-data-0.3.16.tar.gz
  • Upload date:
  • Size: 33.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.9

File hashes

Hashes for edc-list-data-0.3.16.tar.gz
Algorithm Hash digest
SHA256 6cfbb9f10e3d1115a0d2e1055bd923d321b08ce26b94ce5f8e8ff23f74847a0c
MD5 d86488a789d679a864e97b0d7cd81423
BLAKE2b-256 77edc869c5c23ce2235c60b565a590f0904405d444bf29add4e86ec23365c057

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for edc_list_data-0.3.16-py3-none-any.whl
Algorithm Hash digest
SHA256 12e04ddf8eacf7fdd6543d15c7f9585c8010ec0ec26fa589305c5d77baf4ae26
MD5 ad6b7789714d495b5caedae18aa5a6ce
BLAKE2b-256 4c70bb0a860b215a754017a509f748cbc9609d5a6f9a01bfa060f27c83b14dd6

See more details on using hashes here.

Supported by

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