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.
* 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>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/26069#comment:2>
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>
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>
* status: new => closed
* resolution: => worksforme
--
Ticket URL: <https://code.djangoproject.com/ticket/26069#comment:5>
* cc: tzanke@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/26069#comment:6>