Disable Form Fields

A snippet showing how to disable form fields in Django.


# forms.py

from django import forms

class ProfileForm(forms.Form):
    email = forms.EmailField()
    plan = forms.CharField()

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # Disable email (read-only display in form)
        self.fields["email"].disabled = True
      
Explanation:
  • Use field.disabled = True (preferred) rather than HTML-only readonly.
  • Disabled fields are excluded from validation and cleaned_data.
  • Category Forms & Validation
  • Total Views 857
  • Last Modified 14 November, 2025
  • Tags #forms #ui #disabled #fields
Previous snippet
Required vs Optional Fields
Next snippet
Hidden Form Fields
Never miss a story on Django.wiki

Subscribe for fresh tutorials, snippets, and updates.

By subscribing you agree to our Privacy Policy.