Move help_text definitions from model forms to models #7427

Closed
opened 2025-12-29 20:23:23 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Dec 27, 2022).

Originally assigned to: @jeremystretch on GitHub.

Proposed Changes

Move all help_text definitions on model forms to their relevant models, where applicable. For instance, consider ProviderForm:

class ProviderForm(NetBoxModelForm):
    class Meta:
        help_texts = {
            'name': _("Full name of the provider"),
        }

The help text for the name field should be moved to the Provider model:

class Provider(PrimaryModel):
    name = models.CharField(
        max_length=100,
        unique=True,
        help_text=_("Full name of the provider")
    )

Justification

Model forms will automatically infer help text from their associated models. Defining the help text on the model keeps it closer to the field itself and allows it to be referenced for other uses (e.g. API serializers).

Originally created by @jeremystretch on GitHub (Dec 27, 2022). Originally assigned to: @jeremystretch on GitHub. ### Proposed Changes Move all `help_text` definitions on model forms to their relevant models, where applicable. For instance, consider `ProviderForm`: ```python class ProviderForm(NetBoxModelForm): class Meta: help_texts = { 'name': _("Full name of the provider"), } ``` The help text for the `name` field should be moved to the `Provider` model: ```python class Provider(PrimaryModel): name = models.CharField( max_length=100, unique=True, help_text=_("Full name of the provider") ) ``` ### Justification Model forms will automatically infer help text from their associated models. Defining the help text on the model keeps it closer to the field itself and allows it to be referenced for other uses (e.g. API serializers).
adam added the status: acceptedtype: housekeeping labels 2025-12-29 20:23:23 +01:00
adam closed this issue 2025-12-29 20:23:23 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7427