Last active
March 27, 2019 17:47
-
-
Save walison17/5e02ad541898b2168d007aa36312da12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SerializerCollection(ModelSerializer): | |
class Meta: | |
model = Collection | |
fields = ['id', 'name_collection','collector'] | |
read_only_fields = ['collector'] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CollectionListCreate(ListCreateAPIView): | |
permission_classes = (IsAuthenticated,) | |
serializer_class = SerializerCollection | |
def get_queryset(self): | |
user = self.request.user | |
return Collection.objects.filter(collector=user) | |
def perform_create(self, serializer): | |
serializer.save(collector=self.request.user) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment