How to use 'how to change django admin text' in Python

Every line of 'how to change django admin text' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
42def patch_admin_forms(sender, **kwargs):
43 """
44 Disables the `email` field of the user creation/change forms used by
45 `django.contrib.admin`, since `pre_save_email_as_username` sets `email` =
46 `username`
47 """
48 username = sender.fields['username']
49 sender.fields['username'] = forms.EmailField(label=username.label,
50 help_text=username.help_text, max_length=username.max_length)
51 if 'email' in sender.fields:
52 # TODO: It actually really doesn't make sense that this field is visible
53 # at all
54 sender.fields['email'].widget.attrs['disabled'] = True

Related snippets