关于django通过表单写入数据库的时候,views的问题:没有经过前端的填写过程就直接跳转页面了

def task_take_goods(request):
if request.method == "POST":
goods_portrait = request.POST.get('goods_portrait', None)
goods_category = request.POST.get(' goods_category', None)
goods_prize = request.POST.get('goods_prize', None)
goods_description = request.POST.get('goods_description', None)
goods_name = request.POST.get('goods_name', None)
models.Goods.objects.create(
goods_name = goods_name,
goods_portrait = goods_portrait,
goods_category = goods_category,
goods_prize = goods_prize,
goods_description = goods_description
)
return render(request, 'tasktake/task_take_division.html')

蝴蝶刀刀
浏览 723回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP