@commit_on_success with Class based view in Django 1.3

506 views
Skip to first unread message

Yann

unread,
Feb 15, 2012, 11:14:50 AM2/15/12
to Django users
Hi,

In a class view, I am trying to modify two instances of different
models. There are some identical data stored in both tables. They
should really be the same in any circumstance .

Should I use "@commit_on_success"?

If I should, how should i use it for the class based view?

Should I do something like this?

class CreateSomethingView(CreateView):

""
""
@method_decorator(transaction.commit_on_succes)
def post(self):
""


赵帅

unread,
Feb 15, 2012, 12:52:16 PM2/15/12
to django...@googlegroups.com
The commit_on_success decorator only garrentees that one commit is done when no exception is raised from the function and rollback if there is any .
You have to ensure on your own hand the values in the two tables are equal.

2012/2/15 Yann <yann....@gmail.com>


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


Yann

unread,
Feb 15, 2012, 9:01:34 PM2/15/12
to Django users
Thanks. But the more important question is how to use
commit_on_success with class based view?



On Feb 16, 1:52 am, 赵帅 <rostin...@gmail.com> wrote:
> The commit_on_success decorator only garrentees that one commit is done
> when no exception is raised from the function and rollback if there is any .
> You have to ensure on your own hand the values in the two tables are equal.
>
> 2012/2/15 Yann <yann.l....@gmail.com>

Matt Schinckel

unread,
Feb 15, 2012, 11:03:16 PM2/15/12
to django...@googlegroups.com

Yann

unread,
Feb 16, 2012, 12:52:18 AM2/16/12
to Django users
but on which method of the class view?

the post method?

On Feb 16, 12:03 pm, Matt Schinckel <m...@schinckel.net> wrote:
> You can use the @method_decorator decorator decorator.
>
> https://docs.djangoproject.com/en/dev/topics/class-based-views/#decor...
Reply all
Reply to author
Forward
0 new messages