| 287 | field_classes = {"username": UsernameField} |
| 288 | |
| 289 | def __init__(self, *args, **kwargs): |
| 290 | super().__init__(*args, **kwargs) |
| 291 | password = self.fields.get("password") |
| 292 | if password: |
| 293 | if self.instance and not self.instance.has_usable_password(): |
| 294 | password.help_text = _( |
| 295 | "Enable password-based authentication for this user by setting a " |
| 296 | "password." |
| 297 | ) |
| 298 | user_permissions = self.fields.get("user_permissions") |
| 299 | if user_permissions: |
| 300 | user_permissions.queryset = user_permissions.queryset.select_related( |
| 301 | "content_type" |
| 302 | ) |
| 303 | |
| 304 | |
| 305 | class AuthenticationForm(forms.Form): |