About Getting All Field Names

You can print out the names of all fields of a model by this snippet:

1
2
3
4
>>> from myapp.models import MyModel

>>> for field in MyModel._meta.get_fields():
...    print(field.name)

Tips and Tricks Programming Django 4.2 Django 3.2 Django 2.2