Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
162 views
in Technique[技术] by (71.8m points)

python - The foreign key column in my model shows its model name in frontend - django

I have a model named PurchaseMaster with a foreign-key partyidfk from model Parties Now when I fetch data and print my table, it shows model name along with partyidfk values like below[enter image description here][1]My models.py and views.py code and HTML code is as below[enter image description here][2][enter image description here][3][enter image description here][4][enter image description here][5] [1]: https://i.stack.imgur.com/5bzsj.png [2]: https://i.stack.imgur.com/DqOvd.png [3]: https://i.stack.imgur.com/9kZxZ.png [4]: https://i.stack.imgur.com/lbxfG.png [5]: https://i.stack.imgur.com/6QSSt.png

question from:https://stackoverflow.com/questions/65939739/the-foreign-key-column-in-my-model-shows-its-model-name-in-frontend-django

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The problem is, that you should add a str function to your model check out this link django framework documents model


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...