#djoser + rest. Auth. Unable to create account.

58 messages · Page 1 of 1 (latest)

rough matrix
#

Hello I have some troubles

#

That is cusom manager

#

Custom user model

#

So

#

i do this request to my server to create a user, like i ve seen an example in official docs

#

And receive Unable to create account

#

I dont know where is the problem

#

I ve added djoser to INSTALLED APS

ebon ruin
#

Firstly please look at #readme-1st about sharing code snippets.

Secondly a link to djoser would help if that is the documentation you are referring to.

Finally based on the last script you shared I don't believe most of the code is used. What is the JSON response from your script?
Is there an error from your server?

rough matrix
ebon ruin
#

A bad request means that the request is incorrect in some way

#

It could be any number of issues.

rough matrix
#

(((

ebon ruin
#

It's also worth noting that you are not calling the userviewset you have defined. But something within djoser

rough matrix
#

Userviewset()

#

@ebon ruin

#

???

ebon ruin
#

Could you write in full sentences please

rough matrix
#

Even if i make requests by form

#

I receive the same error

#

These are the logs

#
from rest_framework import viewsets, permissions

from django.contrib.auth import get_user_model
from RestServer.models import Transaction

from RestServer.serializers import UserSerializer, TransactionSerializer


Users = get_user_model()


class UserViewSet(viewsets.ModelViewSet):
    queryset = Users.objects.all()
    serializer_class = UserSerializer
    permission_classes = [permissions.IsAuthenticated]




class TransactionViewSet(viewsets.ModelViewSet):
    queryset = Transaction.objects.all()
    serializer_class = TransactionSerializer
    permission_classes = [permissions.IsAuthenticated]

#

Are views right?

ebon ruin
#

You are not using those views fro what I can tell of your urls.py.

/auth/users is within djoser.urls so you would need to follow their docs.

Your Userviewset is just /users from what I can tell

rough matrix
#

ah okey

#
from django.urls import path, include
from RestServer.views import *
from rest_framework import routers


router = routers.SimpleRouter()

router.register('auth/groups/', TransactionViewSet)
router.register('auth/users/', UserViewSet)

urlpatterns = [
    path('', include(router.urls)),
    # path('test/', UserView.as_view()),
    path('auth/', include('djoser.urls')),
]```
#

It doesnt work that way

#

okey

#

so what request should i send

#

In docs they use curl

#

I also used it but i get some other errors, and even though why shouldnt i be able to make the same thing using my code

#

He writes that: "password" is not a command

#

and that email and password are required though i ve passed them like in docs

#

Her

#

zr

#
curl -X POST http://127.0.0.1:8000/auth/users/ --data 'email=tabalex7777@gmail.com&password=alpine12'
#

I make that

ebon ruin
#

Are using djoser or not?

rough matrix
#

Ye

ebon ruin
#

Then why have you replaced it with

router.register('auth/users/', UserViewSet)
#

You seem to be misunderstanding what URLs you have configured

rough matrix
#

Yes i at least tryed )))

#

But i removed auth/

rough matrix
#

So how does request look like? @ebon ruin

ebon ruin
#

I don't know since I haven't every used djoser myself

rough matrix
#

(((