38๐
โ
You can create user from command line using below method:
user@hostname$ python3 -m django shell
>>> import django.contrib.auth
>>> User = django.contrib.auth.get_user_model()
>>> user = User.objects.create_user(username='username', password='userpassword')
Observations:
- A User created, is available for the whole project and not just a single app
- By default,
is_superuser
andis_staff
are bothFalse
when aUser
is created unless they are overwritten by passing increate_user()
method.
๐คAstik Anand
2๐
If you haver extended the base user model then change the first command in @Astik Anand answer to:
from django.contrib.auth import get_user_model
User = get_user_model()
- Django/Python: generate pdf with the proper language
- Docker compose for production and development
- Selenium.common.exceptions.InvalidCookieDomainException: Message: invalid cookie domain while executing tests in Django with Selenium
Source:stackexchange.com