diff --git a/server/users/models.py b/server/users/models.py index 7057057f..8fc62cfa 100644 --- a/server/users/models.py +++ b/server/users/models.py @@ -367,7 +367,10 @@ class License(models.Model): if not is_aware(expiry_date): expiry_date = make_aware(expiry_date) - return expiry_date >= now >= expiry_date - timedelta(days=licenses[isbn]['duration']) + try: + return expiry_date >= now >= expiry_date - timedelta(days=licenses[isbn]['duration']) + except KeyError: # this can happen if the platform changed, e.g. during local testing + return False def __str__(self): return f'License for role: {self.for_role}'