ReadOnlyPasswordHashWidget
This class provides a read-only widget for displaying password hash information within a form. It determines whether a password is set or usable to provide an appropriate label for a password management button. The widget uses a specific template to render the hash status and ensures that no label ID is associated with the field.
Attributes
| Attribute | Type | Description |
|---|---|---|
| template_name | string = auth/widgets/read_only_password_hash.html | The path to the HTML template used to render the read-only password hash widget. |
Methods
get_context()
@classmethod
def get_context(
name: string,
value: string,
attrs: dict
) - > dict
Prepares the template context for rendering the widget, determining whether to display a 'Reset' or 'Set' password button based on the password's usability.
Parameters
| Name | Type | Description |
|---|---|---|
| name | string | The name of the form field associated with this widget. |
| value | string | The hashed password string used to determine if the password is currently set or unusable. |
| attrs | dict | Additional HTML attributes to be rendered on the widget element. |
Returns
| Type | Description |
|---|---|
dict | A dictionary containing template variables, including the appropriate button label for the password state. |
id_for_label()
@classmethod
def id_for_label(
id_: string
) - > null
Returns None to indicate that this read-only widget should not be associated with a clickable label element.
Parameters
| Name | Type | Description |
|---|---|---|
| id_ | string | The HTML ID of the widget element. |
Returns
| Type | Description |
|---|---|
null | Always returns None as the widget does not support label focus. |