我定义了以下视图
//get delta
var delta = Input.GetTouch(0).deltaPosition;
//get position
var pos = lup.transform.position;
//add delta with clamp
pos.x = Mathf.Clamp(pos.x + delta.x, minX, maxX);
pos.y = Mathf.Clamp(pos.y + delta.y, minY, maxY);
//set pos
lup.transform.position = pos;
以下是该应用的urls.py
from django.shortcuts import render, redirect, HttpResponse
from .forms import UploadFileForm
from .models import LoadedData
def loaded_data(request):
return HttpResponse("File successfully uploaded")
def collect_data(request):
if request.method == 'POST':
form = UploadFileForm(request.POST, request.FILES)
if form.is_valid():
instance = LoadedData(data=request.FILES['file'])
instance.save()
return redirect('loaded_data')
else:
form = UploadFileForm()
return render(request, 'pages/app_load_data.html', {'form': form})
这是我上传文件时from django.urls import path
from . import views
urlpatterns = [
path('', views.collect_data, name='collect_data'),
path('loaded_data/', views.loaded_data, name='loaded_data')
]
的结果
python manage.py runserver
但loaded_data没有呈现任何内容,应用程序停留在同一页面上。