[Django] #26069: Docs for MyModel._meta.get_fields_with_model() missing info about 'is_relation'

17 views
Skip to first unread message

Django

unread,
Jan 11, 2016, 6:37:27 AM1/11/16
to django-...@googlegroups.com
#26069: Docs for MyModel._meta.get_fields_with_model() missing info about
'is_relation'
----------------------------------------------+--------------------
Reporter: srkunze | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer (models, ORM) | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
https://docs.djangoproject.com/en/1.9/ref/models/meta/#migrating-old-meta-
api

Docs use source code a explanation:

{{{
MyModel._meta.get_fields_with_model():

[
(f, f.model if f.model != MyModel else None)
for f in MyModel._meta.get_fields()
if not f.is_relation
or f.one_to_one
or (f.many_to_one and f.related_model)
]
}}}

1) Why does {{{ get_fields_with_model }}} return fields with {{{not
is_relation}}}?

2) When does a {{{many_to_one}}} field not have a {{{related_model}}}?

3) Is it possible to have a {{{one_to_one}}} field with no
{{{related_model}}}?

--
Ticket URL: <https://code.djangoproject.com/ticket/26069>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 11, 2016, 7:04:30 AM1/11/16
to django-...@googlegroups.com
#26069: Docs for MyModel._meta.get_fields_with_model() missing info about
'is_relation'
-------------------------------------+-------------------------------------
Reporter: srkunze | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* component: Database layer (models, ORM) => Documentation
* needs_better_patch: => 0
* type: Uncategorized => Cleanup/optimization
* needs_tests: => 0
* needs_docs: => 0


Comment:

1. This excludes non-relational fields I believe.
2. `GenericForeignKey` I think.
3. I don't think so.

Feel free to submit a patch if you are able.

--
Ticket URL: <https://code.djangoproject.com/ticket/26069#comment:1>

Django

unread,
Jan 11, 2016, 7:09:26 AM1/11/16
to django-...@googlegroups.com
#26069: Docs for MyModel._meta.get_fields_with_model() missing info about
'is_relation'
--------------------------------------+------------------------------------
Reporter: srkunze | Owner: nobody
Type: Cleanup/optimization | Status: new

Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/26069#comment:2>

Django

unread,
Jan 11, 2016, 8:27:05 AM1/11/16
to django-...@googlegroups.com
#26069: Docs for MyModel._meta.get_fields_with_model() missing info about
'is_relation'
--------------------------------------+------------------------------------
Reporter: srkunze | Owner: nobody

Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by knbk):

What these attributes mean and when they're set is documented in the
[https://docs.djangoproject.com/en/1.9/ref/models/fields/#model-field-
attributes Field attribute reference].

--
Ticket URL: <https://code.djangoproject.com/ticket/26069#comment:3>

Django

unread,
Jan 13, 2016, 6:47:46 AM1/13/16
to django-...@googlegroups.com
#26069: Docs for MyModel._meta.get_fields_with_model() missing info about
'is_relation'
--------------------------------------+------------------------------------
Reporter: srkunze | Owner: nobody

Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by srkunze):

After reading the docs again, we discovered the original intention. We
found it would help just to add "old" and "new".

{{{
old:
MyModel._meta.get_fields_with_model():

new:


[
(f, f.model if f.model != MyModel else None)
for f in MyModel._meta.get_fields()
if not f.is_relation
or f.one_to_one
or (f.many_to_one and f.related_model)
]
}}}

This would need to be repeated for all deprecated functions but would make
the intention clear.

--
Ticket URL: <https://code.djangoproject.com/ticket/26069#comment:4>

Django

unread,
Jan 13, 2016, 9:55:10 AM1/13/16
to django-...@googlegroups.com
#26069: Docs for MyModel._meta.get_fields_with_model() missing info about
'is_relation'
-------------------------------------+-------------------------------------
Reporter: srkunze | Owner: nobody
Type: | Status: closed
Cleanup/optimization |

Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
| worksforme

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by srkunze):

* status: new => closed
* resolution: => worksforme


--
Ticket URL: <https://code.djangoproject.com/ticket/26069#comment:5>

Django

unread,
Jan 28, 2016, 3:11:03 AM1/28/16
to django-...@googlegroups.com
#26069: Docs for MyModel._meta.get_fields_with_model() missing info about
'is_relation'
-------------------------------------+-------------------------------------
Reporter: srkunze | Owner: nobody

Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
| worksforme
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by TZanke):

* cc: tzanke@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/26069#comment:6>

Reply all
Reply to author
Forward
0 new messages