Skip to main content

Populate list data and other static model data on startup

Project description

pypi travis coverage


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 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):

An example

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.

Files for edc-list-data, version 0.1.26
Filename, size File type Python version Upload date Hashes
Filename, size edc_list_data-0.1.26-py3-none-any.whl (22.6 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page