1

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?

anduplats
  • 885
  • 2
  • 14
  • 24

2 Answers2

1

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

Linovia
  • 19,812
  • 4
  • 47
  • 48
0
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)
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-ask). – Community Sep 20 '21 at 15:19