我正在使用引导程序模板。但是在将配置文件信息保存到数据库中出现了问题。这是我的代码。我不知道我是否做对了。但是它不起作用。models.pyclass Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) Propic = models.ImageField(upload_to="Banners/", null=True,blank=True) bio = models.TextField(max_length=500, blank=True) location = models.CharField(max_length=30, blank=True)views.pydef profile(request):ids = request.user.iduser = User.objects.get(pk=ids)if request.method == "POST": bio = request.POST["bio"] location = request.POST["location"] image = request.FILES['pic'] form = user.profile(bio = bio , location = location , propic=image) form.save() return HttpResponse("info saved")return render(request, "dashbord/user.html", {"user": user })
添加回答
举报
0/150
提交
取消