1. After building a project and open admin site
2. input this command in terminal
- $:manage.py shell
3. Then input this in the python shell. This code will create a "admin" superuser
- >>> from django.contrib.auth.models import User
- >>> user = User.objects.create_user('admin', 'admin@qq.com', '12345')
- >>> user.is_superuser = True
- >>> user.save()
Ps. only superuser can edit "admin" site's content
4. If user need to change password or some attributes
- >>> from django.contrib.auth.models import User
- >>> u = User.objects.get(username__exact='admin')
- >>> u.set_password('new password')
- >>> u.save()
References: https://docs.djangoproject.com/en/1.4/topics/auth/#topics-auth-creating-superusers