Off the top of my head, you can just override the perform_create()
method:
class PhotoListAPIView(generics.ListCreateAPIView):
...
def perform_create(self, serializer):
serializer.save(user=self.request.user)
Give that a shot and let me know if it works
More Related Contents:
- Django Rest Framework remove csrf
- Django rest framework, use different serializers in the same ModelViewSet
- How do I create multiple model instances with Django Rest Framework?
- Django rest framework nested self-referential objects
- Custom error messages in Django Rest Framework serializer
- Django REST Framework: adding additional field to ModelSerializer
- How to change field name in Django REST Framework
- How do you use the django-filter package with a list of parameters?
- Django Rest Framework: Dynamically return subset of fields
- Django Rest Framework with ChoiceField
- SocketException: OS Error: Connection refused, errno = 111 in flutter using django backend
- 405 POST method not allowed
- “Post Image data using POSTMAN”
- CSRF Failed: CSRF token missing or incorrect
- How to register users in Django REST framework?
- AngularJS + Django Rest Framework + CORS ( CSRF Cookie not showing up in client )
- How do you filter a nested serializer in Django Rest Framework?
- How to get Request.User in Django-Rest-Framework serializer?
- Pass request context to serializer from Viewset in Django Rest Framework
- Django Rest Framework: Disable field update after object is created
- Adding root element to json response (django-rest-framework)
- Token Authentication for RESTful API: should the token be periodically changed?
- Authorization Credentials Stripped — django, elastic beanstalk, oauth
- How to programmatically call a Django Rest Framework view within another view?
- Django REST Framework image upload
- Django/DRF – 405 Method not allowed on DELETE operation
- How to pass extra context to Django Rest Framework serializers
- How can I test binary file uploading with django-rest-framework’s test client?
- Django Rest framework, how to include ‘__all__’ fields and a related field in ModelSerializer ?
- context in nested serializers django rest framework