Py学习  »  oolocal  »  全部回复
回复总数  2
7 年前
回复了 oolocal 创建的主题 » Django如何将页面的文本框设置成readonly?

@chengx2000 Setting the TextField to disable will cause the data cannot be submitted from a form, which is not good for me. Thank you though.

7 年前
回复了 oolocal 创建的主题 » Django如何将页面的文本框设置成readonly?

@Django中国社区 Thanks, this really helps. And actually I use another way to make the TextField readonly by setting the 'readonly' attribute in init() function: def init(self, *args, kwargs): super(forms.Form, self).__init__(*args,kwargs) self.fields['user_id'].widget.attrs['readonly'] = True self.fields['user_name'].widget.attrs['readonly'] = True self.fields['email'].widget.attrs['readonly'] = True