Skip to content

Commit

Permalink
fix(profile-form): fix for empty profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoeejoee committed Nov 13, 2023
1 parent f9fddfe commit 7b05e33
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions fiesta/apps/accounts/forms/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,14 @@ class Meta:
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

if up := self.instance: # type: UserProfile
try:
user: User | None = self.instance and self.instance.user
except User.DoesNotExist:
user = None

if user:
for f in USER_FIELDS:
self.initial[f] = getattr(up.user, f, None)
self.initial[f] = getattr(user, f, None)

def save(self, commit=True):
instance: UserProfile = super().save(commit=commit)
Expand Down

0 comments on commit 7b05e33

Please sign in to comment.