format
This commit is contained in:
@ -2,5 +2,5 @@ from django.apps import AppConfig
|
||||
|
||||
|
||||
class LibrosConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'app.libros'
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "app.libros"
|
||||
|
@ -22,4 +22,4 @@ class Libros(models.Model):
|
||||
verbose_name_plural = "Libros"
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
return self.title
|
||||
|
@ -14,9 +14,8 @@ def ping(request):
|
||||
|
||||
|
||||
class LibrosList(APIView):
|
||||
|
||||
def get(self, request):
|
||||
libros = Libros.objects.all().order_by('created_at')
|
||||
libros = Libros.objects.all().order_by("created_at")
|
||||
serializer = LibroSerializer(libros, many=True)
|
||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||
|
||||
@ -29,7 +28,6 @@ class LibrosList(APIView):
|
||||
|
||||
|
||||
class LibrosDetails(APIView):
|
||||
|
||||
def get(self, request, pk):
|
||||
libro = Libros.objects.filter(pk=pk).first()
|
||||
if libro:
|
||||
@ -37,7 +35,6 @@ class LibrosDetails(APIView):
|
||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||
return Response(status=status.HTTP_404_NOT_FOUND)
|
||||
|
||||
|
||||
def put(self, request, pk):
|
||||
libro = Libros.objects.filter(pk=pk).first()
|
||||
serializer = LibroSerializer(libro, data=request.data)
|
||||
@ -46,7 +43,6 @@ class LibrosDetails(APIView):
|
||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
|
||||
def delete(self, request, pk):
|
||||
libro = Libros.objects.filter(pk=pk).first()
|
||||
if libro:
|
||||
|
Reference in New Issue
Block a user