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


Docs use source code a explanation:


    (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 Changed 8 years ago by Tim Graham

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 Changed 8 years ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:3 Changed 8 years ago by Marten Kenbeek

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

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

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

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

Resolution: worksforme
Status: newclosed

comment:6 Changed 8 years ago by TZanke

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