From d969bd33d869a7772db0e263b6f44a6947155416 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Fri, 7 Aug 2020 14:41:50 +0200 Subject: [PATCH] Make django community auth plugin only save changed fields --- tools/communityauth/sample/django/auth.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/communityauth/sample/django/auth.py b/tools/communityauth/sample/django/auth.py index 96221a3c..9d321b66 100644 --- a/tools/communityauth/sample/django/auth.py +++ b/tools/communityauth/sample/django/auth.py @@ -109,18 +109,18 @@ def auth_receive(request): try: user = User.objects.get(username=data['u'][0]) # User found, let's see if any important fields have changed - changed = False + changed = [] if user.first_name != data['f'][0]: user.first_name = data['f'][0] - changed = True + changed.append('first_name') if user.last_name != data['l'][0]: user.last_name = data['l'][0] - changed = True + changed.append('last_name') if user.email != data['e'][0]: user.email = data['e'][0] - changed = True + changed.append('email') if changed: - user.save() + user.save(update_fields=changed) except User.DoesNotExist: # User not found, create it!