본문 바로가기

오늘의 오류들/Django

django admin 아이디 만들기

장고에서 관리자 계정으로 들어가려는데 아이디가 기억이 나지 않아서 먼저 찾아보기로 했습니다.

 

터미널에서 python manage.py shell 로 들어가 

 

from django.contrib.auth.models import User

 

 

장고의 User모듈을 임포트 하고 

 

superusers =  User.object.filter(is_superuser=True)

superusers라는 이름에 User모듈 메서드를 사용해 배정하고

 

superusers를 호출한결과 아무것도 나오지 않았습니다.


그래서 superuser(관리자)id를 만들기로 했습니다. 아래처럼 하시면 됩니다. 

 

python manage.py createsuperuser

 

 

 


만약 비밀번호를 까먹었다면 아래와 같이 바꾸면 됩니다.

 

 

python manage.py changepassword 만든아이디

 


결과