Opened 4 years ago

Closed 4 years ago

#29211 closed New feature (wontfix)

update_or_create with column named defaults

Reported by: James Pic Owned by: nobody
Component: Database layer (models, ORM) Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently, signature is: update_or_create(defaults=None, kwargs)

This means that it's not possible to with a column named "defaults".

Perhaps it would be better to accept a dict in args, since we reserve kwargs for column names ?

Change History (1)

comment:1 Changed 4 years ago by Jani Tiainen

Resolution: wontfix
Status: newclosed

update_or_create() uses same parameters as get_or_create(), and from the get_or_create() docs:

If you have a field named defaults and want to use it as an exact lookup in get_or_create(), just use 'defaults__exact', like so:

Foo.objects.get_or_create(defaults__exact='bar', defaults={'defaults': 'baz'})

Closing as won't fix.

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