开发者

Django: Why when using auto-populate from a manytomany or foreignkey field I always get the ID?

开发者 https://www.devze.com 2023-01-20 11:12 出处:网络
I have a slug field that I would like to be auto-populated from a value in a many开发者_运维问答tomany. It kind of works as it displays in realtime the ID of the selection in the manytomany field.

I have a slug field that I would like to be auto-populated from a value in a many开发者_运维问答tomany. It kind of works as it displays in realtime the ID of the selection in the manytomany field. The model of the manytomany field has its own def unicode(self) to return a string value with its name but this doesnt appear in the slug.


Django's populate javascript always just uses the value attribute of the coresponding HTML field, which is always the id, it it is a select, no matter how you change your python code! You will need to make a custom js to achieve what you are trying to do!

0

精彩评论

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