Skip to main content

Populate list data and other static model data on startup

Project description

pypi travis 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.

For example:

class Antibiotic(ListModelMixin, BaseUuidModel):

    class Meta(ListModelMixin.Meta):
        pass

An example list_data.py:

from edc_constants.constants import OTHER
from edc_list_data import PreloadData

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')
    ],
}

preload_data = PreloadData(list_data=list_data)

PreloadData will persist the list data in model Antibiotic and maintain the order in which the list items are declared.

See also call to site_list_data.autodiscover called in edc_list_data.apps.AppConfig.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

edc_list_data-0.1.26-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: edc_list_data-0.1.26-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for edc_list_data-0.1.26-py3-none-any.whl
Algorithm Hash digest
SHA256 129daf59df2a4801f5f1522f6630e21f91b1d9f0860f458e24340c476517d961
MD5 4b089700926d7fd77abf73ad26baf540
BLAKE2b-256 393c334ec0bdcb1fcd4f1fbe9e67e6677982905eae5040ccc4430ac3541251be

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