开发者

Django: How can I initialise a Charfield when using Add in an admin form?

开发者 https://www.devze.com 2023-03-10 23:12 出处:网络
I have a Charfield \'status\' [with choices = ((\'A\', \'aaa\'), (\'B\', \'bbb\'), (\'C\', ccc开发者_JAVA技巧\'),)]

I have a Charfield 'status' [with choices = (('A', 'aaa'), ('B', 'bbb'), ('C', ccc开发者_JAVA技巧'),)]

Can I initialise the field in the standard admin form to one of the choices? A drop down appears but no choice is selected by default.


Are you using the default option on the field?

CharField(default='A', choices=(...))
0

精彩评论

暂无评论...
验证码 换一张
取 消