title: Django ModelForm- How to make a form generated uneditable
body: <p>I am learning django form and want to know how to make a model form generated display only.</p>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>class Person(models.Model):
      first_name = models.CharField(max_length=40, null=True)
      last_name = models.CharField(max_length=40, null=True)
      #more fields
  </code></pre>
  
  <p><strong>forms.py</strong></p>
  
  <pre><code>class PersonForm(ModelForm):
      class Meta:
          model = Person
  </code></pre>
  
  <p>To generate a form with some existing data in the database:</p>
  
  <pre><code>person=Person.objects.get(id=someid)
  person_form = PersonForm(instance = person)
  </code></pre>
  
  <p>All the fields in the form are editable in the page. However, I just want to display the data.</p>
  
  <p>After some searching in StackOverflow I found a similar solution <a href="https://stackoverflow.com/questions/7088321/how-to-show-a-django-modelform-field-as-uneditable">how to show a django ModelForm field as uneditable</a> , which teaches how to set <em>individual field</em> uneidtable. </p>
  
  <p>But I want to make the whole form uneditable. Is there any better way to do so instead of setting all the fields as uneditable one by one? </p>
  
  <p>Thank you very much for your help. </p>
  
  <p><strong>Updates:</strong> I find the flowing code helps make the form uneditable, but still not sure whether this is the correct way to do it.</p>
  
  <pre><code>for field in person_form.fields:
              person_form.fields[field].widget.attrs['readonly'] = True
  </code></pre>
  
  <p>Thank you for giving your advice.</p>