This should be wrapped in a try… except Subscription.DoesNotExist block: transitioning from an approved -> denied state willl unsubscribe correctly but for pending -> denied transitions the related subscription doesn't exist.

In any case this situation is also taken care of in the new `update_subscriptions` management command which runs daily on the server: https://github.com/django/djangoproject.com/blob/master/aggregator/management/commands/update_subscriptions.py#L32-L35