models: Ensure UserProfile.user is configured

Message ID
State Accepted
Headers show
  • models: Ensure UserProfile.user is configured
Related show

Commit Message

Stephen Finucane Nov. 4, 2018, 12:43 p.m.
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 <>
Closes: #110
 patchwork/ | 1 +
 1 file changed, 1 insertion(+)


diff --git a/patchwork/ b/patchwork/
index a483dc64..a7eee4db 100644
--- a/patchwork/
+++ b/patchwork/
@@ -194,6 +194,7 @@  class UserProfile(models.Model):
 def _user_saved_callback(sender, created, instance, **kwargs):
         profile = instance.profile
+        profile.user = instance
     except UserProfile.DoesNotExist:
         profile = UserProfile(user=instance)