Я хочу добавить кнопку «NEW» для ForeignKey в ModelForm, как и в административной области, вот мой medical_report модель
class Medical_report(models.Model):
Immunisation = models.ForeignKey(Immunisation, on_delete=models.DO_NOTHING)
Name_of_examining_health_officer = models.CharField(max_length=50)
Name_of_the_Health_facility = models.CharField(max_length=50)
Date_of_medical_examination_of_child = models.DateField()
def __str__(self):
return self.Name_of_the_Health_facility
Здесь мой иммунизация модель
class Immunisation(models.Model):
Date_of_immunisation = models.DateField()
def __str__(self):
return str(self.Immunisation_type)
А вот мой файл form.py
class MedicalReportForm(forms.ModelForm):
class Meta:
model = Medical_report
fields = ['Name_of_examining_health_officer',
'Name_of_the_Health_facility',
'Date_of_medical_examination_of_child',
'Immunisation']