41đź‘Ť
âś…
solution 1
On empty database:
python manage.py createsuperuser
python manage.py dumpdata auth.User --indent 4 > users.json
and in users.json
You have needed fixtures.
solution 2
./manage.py shell
>>> from django.contrib.auth.hashers import make_password
>>> make_password('test')
'pbkdf2_sha256$10000$vkRy7QauoLLj$ry+3xm3YX+YrSXbri8s3EcXDIrx5ceM+xQjtpLdw2oE='
and create fixtures file:
[
{ "model": "auth.user",
"pk": 1,
"fields": {
"username": "admin",
"password": "pbkdf2_sha256$10000$vkRy7QauoLLj$ry+3xm3YX+YrSXbri8s3EcXDIrx5ceM+xQjtpLdw2oE="
"is_superuser": true,
"is_staff": true,
"is_active": true
}
}
]
👤Tomasz Jakub Rup
0đź‘Ť
If you are using pytest-django you can use the existing fixture admin_user.
From RTD:
An instance of a superuser, with username “admin” and password “password” (in case there is no “admin” user yet).
👤romaingz
- [Django]-How to run a celery worker with Django app scalable by AWS Elastic Beanstalk?
- [Django]-How do I match the question mark character in a Django URL?
- [Django]-Warning: Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'
Source:stackexchange.com