[Django] #24436: model's __init__ tries to set all non-concrete fields

3 views
Skip to first unread message

Django

unread,
Mar 2, 2015, 8:32:08 AM3/2/15
to django-...@googlegroups.com
#24436: model's __init__ tries to set all non-concrete fields
-------------------------------+-----------------------
Reporter: ktosiek | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.8alpha1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-----------------------
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.

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

Django

unread,
Mar 2, 2015, 8:33:35 AM3/2/15
to django-...@googlegroups.com
#24436: model's __init__ tries to set all non-concrete fields
-------------------------------------+-------------------------------------

Reporter: ktosiek | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.8alpha1
(models, ORM) |
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 ktosiek):

* cc: tomasz.kontusz@… (added)
* needs_better_patch: => 0
* component: Uncategorized => Database layer (models, ORM)
* needs_tests: => 0
* needs_docs: => 0


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

Django

unread,
Mar 2, 2015, 9:31:32 AM3/2/15
to django-...@googlegroups.com
#24436: model's __init__ tries to set all non-concrete fields
-------------------------------------+-------------------------------------
Reporter: ktosiek | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 1.8alpha1
(models, ORM) |
Severity: Normal | Resolution: invalid
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 ktosiek):

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


Comment:

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

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

Reply all
Reply to author
Forward
0 new messages