Если вы хотите получить все имена полей в модели. Вам не нужно использовать self._meta.many_to_many + self._meta.fields
.
Вы можете просто использовать [field.name for field in model._meta.get_fields()]
.
Обратите внимание, что get_fields
вернет все поля (включая многие-ко-многим и внешний ключ)
Django get_fields:
def get_fields(self, include_parents=True, include_hidden=False):
"""
Returns a list of fields associated to the model. By default, includes
forward and reverse fields, fields derived from inheritance, but not
hidden fields. The returned fields can be changed using the parameters:
- include_parents: include fields derived from inheritance
- include_hidden: include fields that have a related_name that
starts with a "+"
"""