aryan-f / django-rest-api-with-otp

REST API for a mobile app secured using One-Time-Password
0 stars 1 forks source link

createsuperuser can't work (can not create superuser) #2

Open mhsharifi96 opened 4 years ago

mhsharifi96 commented 4 years ago

hi , after install requirements,and run python manage.py createsuperuser I get some Error : can not create superuser !!!

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/home/virux/Documents/school/django-rest-api-with-otp/.env/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/home/virux/Documents/school/django-rest-api-with-otp/.env/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/virux/Documents/school/django-rest-api-with-otp/.env/lib/python3.8/site-packages/django/core/management/base.py", line 328, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/virux/Documents/school/django-rest-api-with-otp/.env/lib/python3.8/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 79, in execute
    return super().execute(*args, **options)
  File "/home/virux/Documents/school/django-rest-api-with-otp/.env/lib/python3.8/site-packages/django/core/management/base.py", line 369, in execute
    output = self.handle(*args, **options)
  File "/home/virux/Documents/school/django-rest-api-with-otp/.env/lib/python3.8/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 189, in handle
    self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
  File "/home/virux/Documents/school/django-rest-api-with-otp/django-rest-api-with-otp/otpauth/models.py", line 20, in create_superuser
    user = self.create_user(phone_number, password=password, **extra_fields)
  File "/home/virux/Documents/school/django-rest-api-with-otp/django-rest-api-with-otp/otpauth/models.py", line 13, in create_user
    user.set_password(password)
  File "/home/virux/Documents/school/django-rest-api-with-otp/django-rest-api-with-otp/otpauth/models.py", line 90, in set_password
    otp = OTP.objects.get(account=self)
  File "/home/virux/Documents/school/django-rest-api-with-otp/.env/lib/python3.8/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/virux/Documents/school/django-rest-api-with-otp/.env/lib/python3.8/site-packages/django/db/models/query.py", line 415, in get
    raise self.model.DoesNotExist(
otpauth.models.DoesNotExist: OTP matching query does not exist.
(.env) virux@virux-K45VD:~/Documents/school/django-rest-api-with-o

can I solve it?

aryan-f commented 4 years ago

How you run manage.py migrate?

mhsharifi96 commented 4 years ago

yes,first run migrate command, and if request to request url django app work and return success(status = 200) and created user, but when I have create new admin in django can't work createsuperuser I guess when run this command,in UserManager just run create_user function and not run create_superuser function