def get_context_data(self, form, **kwargs):
        context = super(LoginView, self).get_context_data(form, **kwargs)
        if self.steps.current == 'token':
            context['device'] = self.get_device()
            context['other_devices'] = [
                phone for phone in backup_phones(self.get_user())
                if phone != self.get_device()]
            try:
                context['backup_tokens'] = self.get_user().staticdevice_set\
                    .get(name='backup').token_set.count()
            except StaticDevice.DoesNotExist:
                context['backup_tokens'] = 0

        context['cancel_url'] = settings.LOGOUT_URL
        return context
Adds user's default and backup OTP devices to the context.
dataset/ETHPy150Open Bouke/django-two-factor-auth/two_factor/views/core.py/LoginView.get_context_data