#35542: BoundField's label and help_text and renderer should be properties not class members -------------------------------------+------------------------------------- Reporter: Christophe Henry | Owner: Type: | Christophe Henry Cleanup/optimization | Status: closed Component: Forms | Version: dev Severity: Normal | Resolution: | worksforme Keywords: | Triage Stage: | Unreviewed Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by Natalia Bidart):
* resolution: => worksforme * status: new => closed Comment: Replying to [comment:2 Christophe Henry]: Hello Christophe, thank you for the extra details. In this sentence below: > But if you do this, you won't get the result you expect when rendering form with `{{ form }}` I would need you to describe in detail what is the expected result from your view, because what I would usually expect is what I get when doing a local test. For reference, this is my form and view, inspired by your code: {{{#!python from django import forms from django.contrib import messages from django.core.exceptions import ValidationError from django.http import HttpResponseRedirect from django.shortcuts import render class FooForm(forms.Form): foo_select = forms.CharField() def __init__(self, user, *args, **kwargs): super().__init__(*args, **kwargs) self.fields["foo_select"].help_text = f"Indicate {user.first_name}'s pet name" def clean_foo_select(self): value = self.cleaned_data.get("foo_select") if value != "fido": raise ValidationError("foo_select should be fido") def foo_view(request): form = FooForm(user=request.user) if request.method == "POST": form = FooForm(user=request.user, data=request.POST) if form.is_valid(): messages.success(request, f"Valid {form.cleaned_data=}! :-)") return HttpResponseRedirect(".") messages.error(request, f"INVALID {form.data=}! :-(") return render(request, "foo.html", {"form": form}) }}} And in my template, the correct help text is shown at all times (on GET, on form submission with errors and on form submission without errors). Because of the above, I'll close as `worksforme`, but please fell free to comment with further details. Ideally you would provide a minimal sample Django project showcasing the issue and describing what you expect to get. Thanks again! Natalia. -- Ticket URL: <https://code.djangoproject.com/ticket/35542#comment:4> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/0107019083e2b009-43e82b9d-aae6-4f0c-812d-040f8ee3e0e5-000000%40eu-central-1.amazonses.com.