我有一个测试模板,允许用户将上传的文件图像以及图像标题作为字符字段添加到用户帐户中。这工作正常。
我现在尝试允许用户编辑已上传的文件图像和图像标题详细信息。
是否可以隐藏图像链接并在其位置显示图像?
我已经阅读了django 文档,搜索了SO和 Google,断断续续地工作了 2 1/2 天,但我仍然无法解决这个问题。
似乎有很多关于如何上传新文件图像的信息,但没有关于如何编辑已上传的文件图像的信息。
这是我的 models.py 代码:
def _get_document_upload_location(instance, filename):
"""
Using a function instead of a lambda to make migrations happy. DO NOT remove or rename this function in the future, as it will break migrations.
@param instance: model instance that owns the FileField we're generating the upload filename for.
@param filename: Original file name assigned by django.
"""
return 'attachments/%d/%s' % (instance.user.id, uuid.uuid4())
class AttachmentDetails(models.Model, FillableModelWithLanguageVersion):
user = …Run Code Online (Sandbox Code Playgroud)