Opened 10 years ago

Closed 10 years ago

#24436 closed Bug (invalid)

model's __init__ tries to set all non-concrete fields

Reported by: Tomasz Kontusz Owned by: nobody
Component: Database layer (models, ORM) Version: 1.8alpha1
Severity: Normal Keywords:
Cc: tomasz.kontusz@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Using kwargs when creating models makes Django try to fill non-concrete fields, even if they were not in those kwargs. This breaks (at least) django-hvad which adds some fields that can't be accessed at all until some other model instance will be created.

It looks like the problem is this line: https://github.com/django/django/blob/5cf96b49e43daea6d4a0ba1c80c45e90c74f4e47/django/db/models/base.py#L380 - it sets field_iter to _meta.fields, and then never filters non-concrete fields out.

Change History (2)

comment:1 by Tomasz Kontusz, 10 years ago

Cc: tomasz.kontusz@… added
Component: UncategorizedDatabase layer (models, ORM)

comment:2 by Tomasz Kontusz, 10 years ago

Resolution: invalid
Status: newclosed

Nevermind, it was user error - I had a django-hvad pseudo-field AND an actual field of the same name.

Note: See TracTickets for help on using tickets.
Back to Top