When I try to save file greater then 10Kb to the server with FileField in Django, I get a 500 error from Nginx.
I've already configured nginx.conf with line "client_max_body_size 20M;" and error changed from 413 to 500.
Files less 10Kb successfully upload to my folder on the server.
models.py
class File(models.Model):
name = models.CharField(max_length=255)
file = models.FileField(upload_to='uploads/')
uploaded_at = models.DateTimeField(default=timezone.now)
def __str__(self):
return self.name
serializers.py
class FileSerializer(serializers.ModelSerializer):
class Meta:
model = File
fields = '__all__'
views.py
class FileViewSet(viewsets.ModelViewSet):
queryset = File.objects.all()
serializer_class = FileSerializer
I found issue solve. I had to add this to the nginx.conf: client_body_temp_path /tmp 1 2; https://github.com/CampbellSoftwareSolutions/docker-osticket/issues/34