﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
26081	Understanding MyModel._meta.get_fields()	Thomas Güttler	nobody	"We try to understand what `MyModel._meta.get_fields()` does.

https://docs.djangoproject.com/en/1.9/ref/models/meta/#django.db.models.options.Options.get_fields

{{{
 Returns a tuple of fields ...
}}}

get_fields() returns two different types of objects:

  * django.db.models.fields
  * ManyToOneRel, OneToOneRel or ManyToManyRel

If you print the items of get_fields() you see the difference:

{{{
<ManyToOneRel: foo.tickettype>
<ManyToOneRel: foo.ticket>
...
foo.Tickettype.id
foo.Tickettype.parent
foo.Tickettype.name
...
}}}

According to the docs you get ""fields"". But you get first Rel-Objects and then DB-fields.

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
{{{
(<ManyToOneRel: admin.logentry>,
 <django.db.models.fields.AutoField: id>,
...
}}}

We are missing a common base class.

The wording is confusing since you speak of ""field"" but get_fields() returns fields and rels.



OK, I was not aware of #24317. I close this issue as a duplicate."	Uncategorized	closed	Database layer (models, ORM)	1.9	Normal	duplicate		tzanke@…	Unreviewed	0	0	0	0	0	0
