render_to_string not working on fieldname.help_text

I’m creating an app for a questionnaire and making use of the model fields help_text attribute, which represents the question of each data field.

For this, I wrote some custom model form:

class CustomModelForm(forms.ModelForm):
    """A customized ModelForm for Django.

    This class extends the base ModelForm class from Django's forms module.
    It provides additional functionality to handle errors and help text for form fields.
    """

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        for field in self.errors:
            attrs = self[field].field.widget.attrs
            attrs.setdefault("class", "")
            attrs["class"] += " is-invalid"

        for field in self.fields:
            try:
                self.fields[field].help_text = self._meta.model._meta.get_field(
                    field
                ).help_text
            except Exception:
                pass

additionally I created a template tag together with a .html:

@register.inclusion_tag("../templates/snippets/radioInlineField.html")
def render_radioInlineInput_field(formfield):
    return {"formfield": formfield}
{% with field=formfield %}
        <div class="col-sm-6 text-start">
        {% if field.help_text %}
            <p class="mb-0">{{ field.help_text }}: </p>
        {% endif %}
        </div>
        <div class="col-sm-6 mt-0 ">
        {% for radio in field %}
        <div class="form-check form-check-inline">
            {{ radio.tag }}
            <label class="form-check-label" for="id_{{ radio.id_for_label }}">{{ radio.choice_label }}</label>
        </div>
        {% endfor %}
        {% for error in field.errors %}
            <div class="invalid-feedback">
                {{ error }}
            </div>
        {% endfor %}
        </div>
{% endwith %}

Now everything works good with it, but if I have Form A (only consisting of the above mentioned type of fields) and Form B (which has a required field) on the same view and validation fails for Form B, the {{ field.help_text }} is not rendered anymore and I can’t find my problem.

I also tried field.help_text|safe same result.

I located it down to this part:

def render(
    request, template_name, context=None, content_type=None, status=None, using=None
):
    """
    Return an HttpResponse whose content is filled with the result of calling
    django.template.loader.render_to_string() with the passed arguments.
    """
    content = loader.render_to_string(template_name, context, request, using=using)
    return HttpResponse(content, content_type, status)

where I can see, that my context has still the correct values and include the form.fields.field.help_text values after a failed validation, but after it run through the render_to_string function the content is missing the field.help_text values.

Does anyone have a hint or idea what the problem might be?

This one worked:

class CustomModelForm(forms.ModelForm):
    """A customized ModelForm for Django.

    This class extends the base ModelForm class from Django's forms module.
    It provides additional functionality to handle errors and help text for form fields.
    """

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # Set field labels from model field help_text before processing errors
        self.set_field_labels()

        # Process form errors to customize field appearance
        self.process_form_errors()

    def set_field_labels(self):
        """Set form field labels to the help_text of the corresponding model field."""
        for field_name, field in self.fields.items():
            try:
                help_text = self._meta.model._meta.get_field(field_name).help_text
                if help_text:
                    field.help_text = help_text
            except Exception as e:
                # Optionally, log the exception if needed
                pass

    def process_form_errors(self):
        """Process form errors to customize field appearance."""
        for field_name in self.errors:
            attrs = self.fields[field_name].widget.attrs
            attrs.setdefault("class", "")
            attrs["class"] += " is-invalid"

Unfortunately I don’t fully understand why this makes a difference, explanation would be much appreciated.