1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

DjangoのSuperUserをターミナルからの変更と削除

Posted at

Django標準のUserモデルを使用の場合が対象ですが、シェルより
下記コマンドでパスワードの変更ができます。

> python3 manage.py shell

>>> from django.contrib.auth.models import User
>>> users = User.objects.all()
>>> user = users[0]
>>> user
<User: hogehoge>
>>> user.set_password('hpge1234')
>>> user.save()
>>>

// control + D

スーパーユーザーをシェルから削除する場合はこちらです。

> python3 manage.py shell

>>> from django.contrib.auth.models import User
>>> User.objects.get(username="hogehoge", is_superuser=True).delete()
(1, {'auth.User': 1})
>>> 

// control + D
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?