def form_valid(self, form):
device = self.get_device()<EOL>device.token_set.all().delete()<EOL>for n in range(self.number_of_tokens):<EOL><INDENT>device.token_set.create(token=StaticToken.random_token())<EOL><DEDENT>return redirect(self.success_url)<EOL>
Delete existing backup codes and generate new ones.