From eed1075771dee95a673cda90328ad93318154d9f Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 7 Mar 2023 16:41:24 +0100 Subject: [PATCH] save with commit for default --- ereuse_devicehub/views.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ereuse_devicehub/views.py b/ereuse_devicehub/views.py index f2cd4bc1..5d3861d9 100644 --- a/ereuse_devicehub/views.py +++ b/ereuse_devicehub/views.py @@ -102,7 +102,7 @@ class UserProfileView(GenericMixin): self.get_context() sanitization_form = SanitizationEntityForm() if g.user.sanitization_entity: - sanitization = list(g.user.sanitization_entity)[0] + sanitization = g.user.sanitization_entity sanitization_form = SanitizationEntityForm(obj=sanitization) self.context.update( { @@ -138,14 +138,13 @@ class SanitizationEntityView(View): def dispatch_request(self): form = SanitizationEntityForm() - db.session.commit() if form.validate_on_submit(): - form.save(commit=False) + form.save() messages.success('Sanitization datas updated successfully!') else: messages.error('Error modifying Sanitization datas!') - db.session.commit() + # db.session.commit() return flask.redirect(flask.url_for('core.user-profile'))