0

I have a model with three fields. I have defined it as Modelform. I have written views to add, read and delete objects of this model. Now when I edit, I want to enable one field. The user can edit this field only. How to do this?

models.py

class MyModel(models.Model):
    Field1 = models.ForeignKey(DiffModel1, null=False)
    Field2 = models.ForeignKey(DiffModel2, null=False)
    Field3 = models.IntegerField(default=0, null=False)
Rk..
  • 753
  • 1
  • 10
  • 27
  • 2
    Take a look: http://stackoverflow.com/questions/324477/in-a-django-form-how-to-make-a-field-readonly-or-disabled-so-that-it-cannot-b – alecxe Apr 21 '14 at 16:25

1 Answers1

0

After going through the previous questions in SO and documentation, I have decided to create a new ModelForm which excludes other fields in the Meta class. I used this new ModelForm only while editing. This solved my problem.

Rk..
  • 753
  • 1
  • 10
  • 27