Note that there are some explanatory texts on larger screens.

plurals
  1. POUpload file with FileField and nginx just throw errors?
    text
    copied!<p>I'm new to Django, I'm learning how to handle uploading file with django, I did the same things with the document, but my nginx just throw out errors, </p> <p>here is my views.py:</p> <pre><code>@csrf_exempt def upload_view(request): if request.method == 'POST': form = UploadItemForm(request.POST, request.FILES) if form.is_valid(): return HttpResponse('successfully uploaded') else: return HttpResponse('upload failed') else: if request.user.is_authenticated(): form = UploadItemForm() return render(request, 'design/upload.html', {'form': form, 'username': request.user.username}) else: return HttpResponse("you have to login") </code></pre> <p>model.py</p> <pre><code>class Item(models.Model): name = models.CharField(max_length = 100) description = models.TextField(max_length = 1000) uploadfile = models.FileField() class UploadItemForm(ModelForm): class Meta: model = Item </code></pre> <p>my template:</p> <pre><code>&lt;form enctype="multipart/form-data" method="post" action="/design/"&gt; {% csrf_token %} {{ form.as_p }} &lt;input type="submit" value="upload" /&gt; &lt;/form&gt; </code></pre> <p>if I upload some text-based file (size is very small), everything is OK, when upload other formats, or large csv file, the code failed on </p> <pre><code>form = UploadItemForm(request.POST, request.FILES) </code></pre> <p>nginx says</p> <blockquote> <p>Sorry, the page you are looking for is currently unavailable. Please try again later.</p> </blockquote> <p>I use nginx+uwsgi+django, so is it related to the uwsgi and nginx setup?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload