Skip to main content

Customize Django form label in realtime

Project description

pypi actions coverage


Customize Django’s form label in realtime

For a sequence of data collection timepoints, we ask the question, “Are you circumcised?”. At some time point we hope the response will be YES, but until then, we need to ask “Since we last saw you, were you circumcised?”. It is a lot better if we can ask, “Since we last saw you in ‘October 2018’, were you circumcised?”, where ‘October 2018’ represents the timepoint from which we got our last reponse.

This module shows how you can insert ‘October 2018’ into the ModelAdmin/ModelForm the form label in realtime.

For example:

For a sequence of data collection timepoints, we ask the question, “Are you circumcised”. At some point we hope the response will be YES. But until then we need to ask “Since we last saw you in October 2018, were you circumcised?”, etc.

from edc_form_label import FormLabel, CustomFormLabel, FormLabelModelAdminMixin

class MyCustomLabelCondition(CustomLabelCondition):
    def check(self, **kwargs):
        if self.previous_obj.circumcised == NO:
            return True
        return False

class MyModelAdmin(FormLabelModelAdminMixin admin.ModelAdmin):

    fieldsets = (
        (None, {
            'fields': (

    custom_form_labels = [
            custom_label='Since we last saw you in {previous_visit}, were you circumcised?',

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-form-label, version 0.3.2
Filename, size File type Python version Upload date Hashes
Filename, size edc_form_label-0.3.2-py3-none-any.whl (21.7 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page