Nisha Patel
Problem:
I use 'choice set' in my model but I can't show their labels in template
In model:
In View:
In template: show damage code but not show damage label
I reed many post about this and try solutions but don't work for me
please help me for solve this problem
Solution:
Please >don't use .values(…) [django-antipaterns]: >.values(…) [Django-doc] provides dictionaries, and other native types, it is a >primitive obsession antipattern [refactoring.guru] and will for example for ForeignKeys return their primary key, not the corresponding model item.
Just let Django wrap these in Malpractice objects, so that it ships with all the logic attached to it:
You access the .name of the .unit then with:
Note: It might be better to use the >@login_required decorator [Django-doc] as a decorator, and thus wrap the function in it like:
Note: normally the name of the fields in a Django model are written in snake_case, not PascalCase, so it should be: Hospital instead of hospital.
Suggested blogs:
>What are common syntax errors and exceptions in Python
>What are the steps to fix error while downloading PDF file- Python
>How to do PHP Decryption from Node.js Encryption?
>How to do PHP gd Installation on Ubuntu?
>How to do Web Scraping with Python?
>How to do wild grouping of friends in Python?
>How to download an entire S3 bucket - Complete Guide
>How to get item details of Woo Commerce in custom email content?