社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

oolocal

oolocal 最近创建的主题
oolocal 最近回复了
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