A
A
Alexey Semyonov2019-05-16 15:01:47
Django
Alexey Semyonov, 2019-05-16 15:01:47

How can I prevent the input field from being changed in a Django form?

Good afternoon, please tell me who knows. I have a form, how do I prevent the user from changing some fields. What would these fields be, but what manipulations with them could not be carried out?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir, 2019-05-16
@iGyry

somefield = forms.CharField(
    widget=forms.TextInput(attrs={'readonly':'readonly'})
)

A
Alexander, 2019-05-16
@UPSA

100% nothing.
There is a magic button in browsers - F12
You can change values ​​in DOM objects. Some people like to block the page until you register - change the properties of the object and continue reading))).
I can even change POST requests.
Do a validation when the form is submitted.

V
Vadim Shatalov, 2019-05-16
@netpastor

https://docs.djangoproject.com/en/2.2/ref/forms/fi...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question