diff --git a/apis_core/apis_entities/forms.py b/apis_core/apis_entities/forms.py index 9ad31f49f..4a77e1abb 100644 --- a/apis_core/apis_entities/forms.py +++ b/apis_core/apis_entities/forms.py @@ -191,33 +191,37 @@ def sort_fields_list(field_names, entity_name): instance = getattr(self, "instance", None) if instance != None: - if instance.start_date_written: - self.fields[ - "start_date_written" - ].help_text = DateParser.get_date_help_text_from_dates( - single_date=instance.start_date, - single_start_date=instance.start_start_date, - single_end_date=instance.start_end_date, - single_date_written=instance.start_date_written, - ) - else: - self.fields[ - "start_date_written" - ].help_text = DateParser.get_date_help_text_default() - - if instance.end_date_written: - self.fields[ - "end_date_written" - ].help_text = DateParser.get_date_help_text_from_dates( - single_date=instance.end_date, - single_start_date=instance.end_start_date, - single_end_date=instance.end_end_date, - single_date_written=instance.end_date_written, - ) - else: - self.fields[ - "end_date_written" - ].help_text = DateParser.get_date_help_text_default() + # same as above, part of TempEntityClass + if "start_date_written" in self.fields: + if instance.start_date_written: + self.fields[ + "start_date_written" + ].help_text = DateParser.get_date_help_text_from_dates( + single_date=instance.start_date, + single_start_date=instance.start_start_date, + single_end_date=instance.start_end_date, + single_date_written=instance.start_date_written, + ) + else: + self.fields[ + "start_date_written" + ].help_text = DateParser.get_date_help_text_default() + + # same as above, part of TempEntityClass + if "end_date_written" in self.fields: + if instance.end_date_written: + self.fields[ + "end_date_written" + ].help_text = DateParser.get_date_help_text_from_dates( + single_date=instance.end_date, + single_start_date=instance.end_start_date, + single_end_date=instance.end_end_date, + single_date_written=instance.end_date_written, + ) + else: + self.fields[ + "end_date_written" + ].help_text = DateParser.get_date_help_text_default() def save(self, *args, **kwargs): obj = super(GenericEntitiesForm, self).save(*args, **kwargs)