开发者

Custom unicode on already created object

开发者 https://www.devze.com 2023-01-06 16:20 出处:网络
I\'m using permissions in my application. And in some case I need to create form only with permission field. I\'m using ModelChoiceField and queryset with permission objects.

I'm using permissions in my application. And in some case I need to create form only with permission field. I'm using ModelChoiceField and queryset with permission objects.

permission = forms.ModelChoiceField开发者_开发技巧(queryset = Permission.objects.all())

But permissions unicode is taking too much place in choice field. And it looks not so good. I want to use in my choice field only permission's name. Is it possible?


You can create a proxy model, and override the __unicode__() method on that.

0

精彩评论

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