create_or_update() shortcut

1,470 views
Skip to first unread message

Jens Diemer

unread,
Aug 2, 2007, 5:01:49 AM8/2/07
to django...@googlegroups.com

We have the shortcut get_or_create() [1], but whats about a create_or_update() ?

[1] http://www.djangoproject.com/documentation/db-api/#get-or-create-kwargs

--
Mfg.

Jens Diemer


----
A django powered CMS: http://www.pylucid.org

Don Arbow

unread,
Aug 2, 2007, 12:01:00 PM8/2/07
to django...@googlegroups.com
On Aug 2, 2007, at 2:01 AM, Jens Diemer wrote:
>
> We have the shortcut get_or_create() [1], but whats about a
> create_or_update() ?
>
> [1] http://www.djangoproject.com/documentation/db-api/#get-or-
> create-kwargs


The shortcut already exists, it's called save().

http://www.djangoproject.com/documentation/db-api/#how-django-knows-
to-update-vs-insert

Don

Nathaniel Whiteinge

unread,
Aug 2, 2007, 4:45:14 PM8/2/07
to Django users
On Aug 2, 3:01 am, Jens Diemer <python_gm...@jensdiemer.de> wrote:
> We have the shortcut get_or_create() [1], but whats about a create_or_update() ?

One exists as a patch_. I've been using it with the current svn for a
while without problems. I find that an update_or_create() shortcut is
particularly helpful working with newforms and use it in quite a few
places. The patch gets pinged every so often [1]_; it will likely make
it into trunk eventually.

.. patch: http://code.djangoproject.com/ticket/3182
.. [1] http://groups.google.com/group/django-developers/search?group=django-developers&q=3182

- whiteinge

Reply all
Reply to author
Forward
0 new messages