About Getting a List of Textual Fields of a Model Instance

To get a list of textual fields of any model instance, you can do this:

from django.db import models

text_field_names = [
    field.name 
    for field in type(instance)._meta.get_fields()
    if isinstance(field, (models.CharField, models.TextField))
]

Tips and Tricks Programming Django 4.2 Django 3.2 Django 2.2