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

Uploaded Source

Built Distribution

edc_list_data-0.3.22-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: edc-list-data-0.3.22.tar.gz
  • Upload date:
  • Size: 34.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for edc-list-data-0.3.22.tar.gz
Algorithm Hash digest
SHA256 2ad067655b9c28dcd45126966517a4a31fb6d65b54e9a595f5648f3684a8b328
MD5 6d56deccc37ff430c4f89c55c993cde7
BLAKE2b-256 7ff70eb0ddd2a5c78228fe1d4f7b2a1b38a75413cfdf39ff198d6ed26d06db8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for edc_list_data-0.3.22-py3-none-any.whl
Algorithm Hash digest
SHA256 b5ca2540337ed9c43da4e7e2f0d40b0662f08cdbf745b864ec7cfc84b495c939
MD5 d418ba31b3463eb647cc0a304fbabdb0
BLAKE2b-256 dd986554ef3d32a0618a40e67c8eef2f6a651eb4c5f5e4aa424595b23ad4058a

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