I have a Django model form that has file fields. Since the files sent by the users are larger, I am submitting the form using xhr request and jQuery. The progress bar works fine on local machine. But it's stuck at 0% when I try the same in pythonanywhere. The file is still uploading but I am unable to track the progress. Once upload finishes I am receiving the success status and all. I am using this library https://github.com/jakobadam/bootstrap-uploadprogress
In my HTML I just call
$("#form").uploadprogress({redirect_url: "my_url"});
My views:::python
def signup_view(request):
status = 200
if request.method == 'POST':
logout(request)
form = SignUpForm(request.POST)
file_form= FileProfileForm(request.POST, request.FILES)
if form.is_valid() and file_form.is_valid():
userObj = form.cleaned_data
username = userObj['username']
email = userObj['email']
password = userObj['password1']
if not (User.objects.filter(email=email).exists()):
user = form.save()
file_inst= file_form.save()
data = {'status': 200, 'message': 'Account created successfully'}
return JsonResponse(data, safe=False)
else:
raise forms.ValidationError('Looks like a username with that email or password already exists')
else:
status = 422
else:
form = SignUpForm
file_form= FileProfileForm(initial={'status': 'Pending'})
context = {'form': form, 'file_form': file_form}
return render(request, 'registration/signup.html', context, status=status)
I am new here so please let me know if I am missing something :)
Thanks in advance