Why are read-only form fields in Django a bad idea?

前端 未结 4 1622
天命终不由人
天命终不由人 2020-12-25 11:40

I\'ve been looking for a way to create a read-only form field and every article I\'ve found on the subject comes with a statement that \"this is a bad idea\". Now for an in

4条回答
  •  青春惊慌失措
    2020-12-25 12:00

    The reason you don't want to do this is because someone can change your disabled field to enabled and then submit the form. You would have to change the save function as to not insert the "disabled" data.

    The standard way to do this is to not put the name in an input, but to display it as text

    Johnny Five

    ....

    This is not possible in django.

    I say if you really trust your userbase to not "mess" with things then go for it, but if its a public facing website with possible sensitive data then stay away.

提交回复
热议问题