Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#26069 closed Cleanup/optimization (worksforme)

Docs for MyModel._meta.get_fields_with_model() missing info about 'is_relation'

Reported by: Sven R. Kunze Owned by: nobody
Component: Documentation Version: 1.8
Severity: Normal Keywords:
Cc: tzanke@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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?

Change History (6)

comment:1 by Tim Graham, 8 years ago

Component: Database layer (models, ORM)Documentation
Type: UncategorizedCleanup/optimization
  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.

comment:2 by Tim Graham, 8 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Marten Kenbeek, 8 years ago

What these attributes mean and when they're set is documented in the Field attribute reference.

comment:4 by Sven R. Kunze, 8 years ago

Last edited 8 years ago by Sven R. Kunze (previous) (diff)

comment:5 by Sven R. Kunze, 8 years ago

Resolution: worksforme
Status: newclosed

comment:6 by TZanke, 8 years ago

Cc: tzanke@… added
Note: See TracTickets for help on using tickets.
Back to Top