Skip to content

Commit

Permalink
Updated readme with docs on generics
Browse files Browse the repository at this point in the history
  • Loading branch information
em1208 committed Aug 3, 2024
1 parent 026d4e4 commit 462ceed
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class AsyncSerializer(Serializer):
views.py

```python
from . import serializers
from .serializers import AsyncSerializer
from adrf.views import APIView

class AsyncView(APIView):
Expand All @@ -149,7 +149,42 @@ class AsyncView(APIView):
"password": "test",
"age": 10,
}
serializer = serializers.AsyncSerializer(data=data)
serializer = AsyncSerializer(data=data)
serializer.is_valid()
return await serializer.adata
```

# Async generics

models.py

```python
from django.db import models

class Order(models.Model):
name = models.TextField()
```

serializers.py

```python
from adrf.serializers import ModelSerializer
from .models import Order

class OrderSerializer(ModelSerializer):
class Meta:
model = Order
fields = ('name', )
```

views.py

```python
from adrf.generics import ListCreateAPIView
from .models import Order
from .serializers import OrderSerializer

class ListCreateOrderView(ListCreateAPIView):
queryset = Order.objects.all()
serializer_class = OrderSerializer
```

0 comments on commit 462ceed

Please sign in to comment.