Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Django superuser name?

Tags:

django

Is there a way to change Django superuser name through cmd windows? If not, what is the other option(s)?

like image 849
Tadas V. Avatar asked Apr 02 '13 14:04

Tadas V.


People also ask

What is my superuser name in Django?

You can open the shell and user is_superuser to search for all the superusers through the console.

Can I create multiple superuser in Django?

The common method to make the admin interface is to place all models in a single admin. Anyway, it is possible to have different admin pages in a single Django application.


1 Answers

When you say "name" it could be either first_name, last_name or the username You can do this:

Open cmd, and navigate to the folder with manage.py There

$ python manage.py shell
> from django.contrib.auth.models import User
> user = User.objects.get(username=<superuser's username>) #or email=<email>
> user.first_name = 'first_name'
> user.last_name = 'last_name'
> user.username = 'username' #make sure it is unique
> user.save()

Another option is to go to your database table auth_user and change it there.

like image 139
karthikr Avatar answered Sep 30 '22 19:09

karthikr