[Django]-Crispy Forms Initial data

9👍

Nothing to do with crispy-forms, this is regular Django forms code. You have forgotten to call parent constructor, if you are using python 2.X do:

def __init__(self, *args, **kwargs):
    super(YourFormClassName, self).__init__(*args, **kwargs)
    self.fields['medical_record_number'].initial = 'whatever you want'

Beware that maybe you prefer to set initial in your Django form field:

whatever = forms.CharField(initial="whatever you want")

Leave a comment