anduplats
anduplats

Reputation: 1003

Creating superuser using POST request Django rest framework 3.5

Hey i have one question about creating superuser with djangorestframework.

If i want to create superuser with console i'll write:

python manage.py createsuperuser

But now i want to create superuser with POST request using DRF 3.5

How should i do that if i'm using Android as a client for example?

Upvotes: 1

Views: 1365

Answers (2)

Aravind S
Aravind S

Reputation: 1

from django.contrib.auth.models import User
    
def save_users(request):
        username = request.GET.get('username')
        email = request.GET.get('email')
        password = request.GET.get('password') 
        users = User.objects.create_user(username, email, password)

Upvotes: 0

Linovia
Linovia

Reputation: 20976

You need to set up a view and serializer around the user that include the is_admin flag.

Upvotes: 1

Related Questions