Skip to content

Instantly share code, notes, and snippets.

@ghostry
Created June 22, 2019 05:59
Show Gist options
  • Save ghostry/57219d950ad0657634e52fba74f22aba to your computer and use it in GitHub Desktop.
Save ghostry/57219d950ad0657634e52fba74f22aba to your computer and use it in GitHub Desktop.
获取Django中model字段名 字段的verbose_name
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