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 Distribution

Built Distribution

edc_list_data-0.1.4-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file edc-list-data-0.1.4.macosx-10.13-x86_64.tar.gz.

File metadata

  • Download URL: edc-list-data-0.1.4.macosx-10.13-x86_64.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for edc-list-data-0.1.4.macosx-10.13-x86_64.tar.gz
Algorithm Hash digest
SHA256 415b8b959b5923f1da35699a542ad82ef85467d66dd340614713f39afdfaf608
MD5 c4595438b17b4f1d0dd3a1973af8f152
BLAKE2b-256 3b6227e765c3f1de0ce0f87929dcd68beae7a987ce22b5898a9cef22c52f1d20

See more details on using hashes here.

File details

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

File metadata

  • Download URL: edc_list_data-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for edc_list_data-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7ae9796741fef1c80729b117a450737671d3370f1a8e80f52a583b695e7afeb8
MD5 01df2283898fae768bd6cb5e742ef762
BLAKE2b-256 fd335cde856b9c26ca781e16e30bfbfcb2b0452645aec2e66146fbbf094aa6a8

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