About Getting the List of All Fields of a Model

When you have models with inheritance and a lot of fields, it might be annoying to collect a list of all fields manually for admin configurations, model forms, and serializers.

Here is a quick way to list all model fields in Django shell for copying and pasting:

1
>>> [f.name for f in MyModel._meta.fields]

Tips and Tricks Development Django 4.x Django 3.2 Django 2.2 Django 1.11 Django 1.8