I have a form:
class SideEffectForm(ModelForm):
class Meta:
model = SideEffect
fields = ['se_name']
def __init__(self, *args, p, **kwargs):
super().__init__(*args, **kwargs)
if p == 'antipsychotic':
self.fields['se_name'].choices = [
("insomnia_and_agitation", "Insomnida and Agitation"),
("akathisia", "Akathisia"),
("dystonia", "Dystonia"),
]
That is based on this model:
class SideEffect(TimeStampedModel):
SE_CHOICES = [
("insomnia_and_agitation", "Insomnida and Agitation"),
("akathisia", "Akathisia"),
("anticholinergic_effects", "Anticholinergic Side Effects")
]
se_name = models.CharField("",max_length=200, choices=SE_CHOICES, blank=False)
concern = models.IntegerField("",default=50)
case = models.ForeignKey(Case, on_delete=models.CASCADE)
I have a form:
class SideEffectForm(ModelForm):
class Meta:
model = SideEffect
fields = ['se_name']
def __init__(self, *args, p, **kwargs):
super().__init__(*args, **kwargs)
if p == 'antipsychotic':
self.fields['se_name'].choices = [
("insomnia_and_agitation", "Insomnida and Agitation"),
("akathisia", "Akathisia"),
("dystonia", "Dystonia"),
]
That is based on this model:
class SideEffect(TimeStampedModel):
SE_CHOICES = [
("insomnia_and_agitation", "Insomnida and Agitation"),
("akathisia", "Akathisia"),
("anticholinergic_effects", "Anticholinergic Side Effects")
]
se_name = models.CharField("",max_length=200, choices=SE_CHOICES, blank=False)
concern = models.IntegerField("",default=50)
case = models.ForeignKey(Case, on_delete=models.CASCADE)
As it stands the form displays the first option. I would however like to have a place holder e.g. ‘Please select a side effect’. I could do this by having it as one of the options but would prefer not to as then would need to implement measures to stop the placeholder being saved as a valid user entry. Is there a way to specify a placeholder?