| 3 | | Pull request coming to improve the docs. |
| | 3 | https://docs.djangoproject.com/en/1.9/ref/models/meta/#django.db.models.options.Options.get_fields |
| | 4 | |
| | 5 | {{{ |
| | 6 | Returns a tuple of fields ... |
| | 7 | }}} |
| | 8 | |
| | 9 | get_fields() returns two different types of objects: |
| | 10 | |
| | 11 | * django.db.models.fields |
| | 12 | * ManyToOneRel, OneToOneRel or ManyToManyRel |
| | 13 | |
| | 14 | If you print the items of get_fields() you see the difference: |
| | 15 | |
| | 16 | {{{ |
| | 17 | <ManyToOneRel: foo.tickettype> |
| | 18 | <ManyToOneRel: foo.ticket> |
| | 19 | ... |
| | 20 | foo.Tickettype.id |
| | 21 | foo.Tickettype.parent |
| | 22 | foo.Tickettype.name |
| | 23 | ... |
| | 24 | }}} |
| | 25 | |
| | 26 | According to the docs you get "fields". But you get first Rel-Objects and then DB-fields. |
| | 27 | |
| | 28 | The example in the docs is the same: https://docs.djangoproject.com/en/1.9/ref/models/meta/#django.db.models.options.Options.get_fields |
| | 29 | {{{ |
| | 30 | (<ManyToOneRel: admin.logentry>, |
| | 31 | <django.db.models.fields.AutoField: id>, |
| | 32 | ... |
| | 33 | }}} |
| | 34 | |
| | 35 | We are missing a common base class. |
| | 36 | |
| | 37 | The wording is confusing since you speak of "field" but get_fields() returns fields and rels. |
| | 38 | |
| | 39 | |
| | 40 | |