Created
June 22, 2019 05:59
-
-
Save ghostry/57219d950ad0657634e52fba74f22aba to your computer and use it in GitHub Desktop.
获取Django中model字段名 字段的verbose_name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_verbose_names(obj, exclude=[]): | |
filed = obj._meta.fields | |
# print(filed) | |
fielddic = {} | |
params = [f for f in filed if f.name not in exclude] | |
for i in params: | |
fielddic[i.name] = i.verbose_name | |
# print(fielddic) | |
return fielddic |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment