Django - Error registro de usuario.

 
Vista:

Error registro de usuario.

Publicado por MarioLesmes (1 intervención) el 08/07/2022 22:37:59
Buenas tardes, cuando ejecuto pruebas en Postman aparece el siguiente error:
TypeError at /user/
'str' object is not callable
Request Method: GET
Request URL: http://127.0.0.1:8000/user/
Django Version: 4.0.5
Exception Type: TypeError
Exception Value:
'str' object is not callable
Exception Location: C:\Nueva carpeta\Escritorio\PROYECTOS DJANGO\P8_Bank_Project\Backend\env\lib\site-packages\rest_framework\views.py, line 272, in <listcomp>
Python Executable: C:\Nueva carpeta\Escritorio\PROYECTOS DJANGO\P8_Bank_Project\Backend\env\scripts\python.exe
Python Version: 3.10.5
Python Path:
['C:\\Nueva carpeta\\Escritorio\\PROYECTOS DJANGO\\P8_Bank_Project\\Backend',
'C:\\Users\\Mario\\AppData\\Local\\Programs\\Python\\Python310\\python310.zip',
'C:\\Users\\Mario\\AppData\\Local\\Programs\\Python\\Python310\\DLLs',
'C:\\Users\\Mario\\AppData\\Local\\Programs\\Python\\Python310\\lib',
'C:\\Users\\Mario\\AppData\\Local\\Programs\\Python\\Python310',
'C:\\Nueva carpeta\\Escritorio\\PROYECTOS '
'DJANGO\\P8_Bank_Project\\Backend\\env',
'C:\\Nueva carpeta\\Escritorio\\PROYECTOS '
'DJANGO\\P8_Bank_Project\\Backend\\env\\lib\\site-packages']
Server time: Fri, 08 Jul 2022 20:33:11 +0000

El url es:
from django.contrib import admin
from django.urls import path
from authAppExample import views as authAppViews
from rest_framework_simplejwt.views import(TokenObtainPairView, TokenRefreshView)

urlpatterns = [
path('admin/', admin.site.urls),
path('login/', TokenObtainPairView.as_view()),
path('refresh/', TokenRefreshView.as_view()),
path('user/', authAppViews.UserCreateView.as_view()),
path('user/<int:pk>/', authAppViews.UserDetailView.as_view()),
path('transaction/', authAppViews.TransactionCreateView.as_view()),
path('transaction/<int:user>/<int:pk>/', authAppViews.TransactionDetailView.as_view()),
path('transaction/<int:user>/<int:account>/', authAppViews.TransactionsAccountView.as_view()),
path('transaction/remove/<int:user>/<int:pk>/', authAppViews.TransactionDeleteView.as_view()),
]


from rest_framework import status, views
from rest_framework.response import Response
from rest_framework_simplejwt.serializers import TokenObtainPairSerializer
from authAppExample.serializers.userSerializers import UserSerializer
from rest_framework.views import APIView
from rest_framework.permissions import IsAuthenticated

class UserCreateView(APIView):

def post(self, request):

serializer = UserSerializer(data=request.data)

serializer.is_valid(raise_exception=True)
serializer.save()

token_data ={"username" : request.data['username'],
'password' : request.data['password']}
token_serializer = TokenObtainPairSerializer(data = token_data)
token_serializer.is_valid(raise_exception=True)
return Response(token_serializer.validated_data, status= status.HTTP_201_CREATED)
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder