diff --git a/hc/accounts/models.py b/hc/accounts/models.py index 72403f44..422a4989 100644 --- a/hc/accounts/models.py +++ b/hc/accounts/models.py @@ -16,12 +16,7 @@ from hc.lib import emails class ProfileManager(models.Manager): def for_user(self, user): - try: - profile = self.get(user_id=user.id) - except Profile.DoesNotExist: - profile = Profile(user=user) - profile.save() - + profile, created = Profile.objects.get_or_create(user_id=user.id) return profile diff --git a/hc/payments/models.py b/hc/payments/models.py index 616d7574..6391bc67 100644 --- a/hc/payments/models.py +++ b/hc/payments/models.py @@ -5,12 +5,7 @@ from django.db import models class SubscriptionManager(models.Manager): def for_user(self, user): - try: - sub = self.get(user_id=user.id) - except Subscription.DoesNotExist: - sub = Subscription(user=user) - sub.save() - + sub, created = Subscription.objects.get_or_create(user_id=user.id) return sub