def handle(self, *args, **options): username = options['username'] try: statictoken = add_static_token(username, options.get('token')) except get_user_model().DoesNotExist: raise CommandError('User "{0}" does not exist.'.format(username)) self.stdout.write(force_text(statictoken.token))
def handle(self, *args, **options): if len(args) != 1: raise CommandError('Please specify exactly one username.') username = args[0] try: statictoken = add_static_token(username, options.get('token')) except get_user_model().DoesNotExist: raise CommandError('User "{0}" does not exist.'.format(username)) self.stdout.write(statictoken.token)
def handle(self, *args, **options): if len(args) != 1: raise CommandError('Please specify exactly one username.') username = args[0] try: statictoken = add_static_token(username, options.get('token')) except get_user_model().DoesNotExist: raise CommandError('User "{0}" does not exist.'.format(username)) print(statictoken.token, file=self.stdout)