[PATCH] models: Ensure UserProfile.user is configured
Stephen Finucane
stephen at that.guru
Sun Nov 4 23:43:29 AEDT 2018
Django Admin seems to be doing something funky with how it's handling
the creation of a User's corresponding UserProfile instance when
modelled as an inline field. Re-setting the UserProfile.user attribute
seems to resolve the issue, so do just that.
Signed-off-by: Stephen Finucane <stephen at that.guru>
Closes: #110
---
patchwork/models.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/patchwork/models.py b/patchwork/models.py
index a483dc64..a7eee4db 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -194,6 +194,7 @@ class UserProfile(models.Model):
def _user_saved_callback(sender, created, instance, **kwargs):
try:
profile = instance.profile
+ profile.user = instance
except UserProfile.DoesNotExist:
profile = UserProfile(user=instance)
profile.save()
--
2.19.1
More information about the Patchwork
mailing list