当用户上传图像并提交注册表单时,我正在尝试将图像保存到文件夹中。你知道吗
在型号.py你知道吗
image = models.ImageField(upload_to=upload_location, null=True, blank=True)
我使用了一个函数upload_location
来上传图像,这里就是
def upload_location(instance, filename):
UserModel = instance.__class__
new_id = UserModel.objects.order_by("id").last().id + 1
return "user/%s/%s" %(new_id,filename)
它在localhost中工作得很好,但当我将代码推送到服务器时,它甚至没有运行函数upload_location
。我做错什么了?你知道吗
编辑: 才知道真正的问题。服务器上没有上载大于15kb的文件。这是django问题还是服务器问题?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐