Opened 11 years ago
Closed 4 years ago
#22640 closed Cleanup/optimization (fixed)
Can create model instance with conflicting args and kwargs value for the same field
Reported by: | Peter Zsoldos | Owned by: | Jacob Walls |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Discovered while working on #18586
To reproduce it, add the following test (it's using tests.basic.models.Article)
from django.utils import six def test_cannot_specify_same_field_with_args_and_kwargs_too(self): six.assertRaisesRegex( self, TypeError, "__init__() got multiple values for argument 'headline'", Article, None, # id 'args based headline', headline='kwargs based headline', pub_date=datetime(2005, 7, 31), )
Change History (7)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Type: | Bug → Cleanup/optimization |
Hi,
From what I understand, *args
instanciation is there for performance reasons (see [1]).
I'll accept this ticket on the basis that it'd be nice to fix it but only if it doesn't impact performance negatively.
Thanks.
Version 0, edited 11 years ago by (next)
comment:4 by , 8 years ago
Description: | modified (diff) |
---|
comment:6 by , 4 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
For what it's worth, I didn't realize there was any attempt to support positional arguments in model instantiation (although it is tested, is it documented anywhere?). May not be worth fixing, in my opinion.