I'm working on a project for a job interview and this is my first experience with django - I'm trying to upload an image to a dropzone and display it on a separate page. I've made the dropzone and the image upload creates a model, but when trying to pass the model into the render of the other page, I get an indentation issue. Here's what my views.py looks like:
from django.http import HttpResponse, JsonResponse
from django.shortcuts import render
from .models import Drop
def index(request):
return render(request, 'dragAndDrop/index.html')
def upload_file(request):
if request.method == 'POST':
myFile = request.FILES.get('file')
Drop.objects.create(image=myFile)
return HttpResponse('')
return JsonResponse({'post':'false'})
def display(request):
drops = Drop.objects.all()
context = {
'drops': drops,
}
return render(request, 'dragAndDrop/display.html', context)
This is the error that I'm getting:
File "/mnt/c/Users/johnf/projUR/mysite/dragAndDrop/urls.py", line 2, in <module>
from . import views
File "/mnt/c/Users/johnf/projUR/mysite/dragAndDrop/views.py", line 20
return render(request, 'dragAndDrop/display.html', context)
^
TabError: inconsistent use of tabs and spaces in indentation
If anyone can offer any assistance, that would be greatly appreciated!