Gets all the fields and relationships on the Django model and its ancestry. Prioritizes local fields and relationships over the reverse relationships of the same name Returns a tuple of (field.name, field)
(model)
| 93 | |
| 94 | |
| 95 | def get_model_fields(model): |
| 96 | """ |
| 97 | Gets all the fields and relationships on the Django model and its ancestry. |
| 98 | Prioritizes local fields and relationships over the reverse relationships of the same name |
| 99 | Returns a tuple of (field.name, field) |
| 100 | """ |
| 101 | local_fields = get_local_fields(model) |
| 102 | local_field_names = {field[0] for field in local_fields} |
| 103 | reverse_fields = get_reverse_fields(model, local_field_names) |
| 104 | all_fields = local_fields + list(reverse_fields) |
| 105 | |
| 106 | return all_fields |
| 107 | |
| 108 | |
| 109 | def is_valid_django_model(model): |
searching dependent graphs…