Pull request coming to improve the docs.
--
Ticket URL: <https://code.djangoproject.com/ticket/26081>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* component: Documentation => Database layer (models, ORM)
* needs_tests: => 0
* needs_docs: => 0
Old description:
> We try to understand what `MyModel._meta.get_fields()` does.
>
> Pull request coming to improve the docs.
New description:
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.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/26081#comment:1>
Comment (by timgraham):
Replacing "rel" objects with real fields is the subject of #24317. Until
then, I'm not sure how to proceed documentation-wise since rel objects
aren't explicitly public API.
--
Ticket URL: <https://code.djangoproject.com/ticket/26081#comment:2>
* status: new => closed
* resolution: => duplicate
Old description:
> 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.
New description:
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.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/26081#comment:3>
* cc: tzanke@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/26081#comment:4>