From fe7cc0211c4b0f0493dad852938f2960e3215151 Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Tue, 2 Oct 2018 15:37:20 +0200
Subject: [PATCH] Update email field

---
 profiles/forms.py  | 2 +-
 profiles/models.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/profiles/forms.py b/profiles/forms.py
index b1152d624..e8dd84e0d 100644
--- a/profiles/forms.py
+++ b/profiles/forms.py
@@ -18,7 +18,7 @@ class ProfileForm(forms.ModelForm):
 
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
-        self.fields['email'].initial = self.instance.email.email
+        self.fields['email'].initial = self.instance.email
 
     def clean_email(self):
         """Check that the email isn't yet associated to an existing Profile."""
diff --git a/profiles/models.py b/profiles/models.py
index dd3d19e45..778726262 100644
--- a/profiles/models.py
+++ b/profiles/models.py
@@ -61,7 +61,7 @@ class Profile(models.Model):
 
     @property
     def email(self):
-        return self.emails.filter(primary=True).first()
+        return getattr(self.emails.filter(primary=True).first(), 'email', '')
 
 
 class ProfileEmail(models.Model):
-- 
GitLab