Django - 删除“当前”在图像编辑表单中,并用实际图像替换它 [英] Django - Remove "Currently" In An Image Edit Form and Replace It With The Actual Image

查看:175
本文介绍了Django - 删除“当前”在图像编辑表单中,并用实际图像替换它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑具有图像字段的对象时,会显示当前图像路径和标准文件上传字段。我想做的是能够用实际的图像替换显示的路径(Currently:/pathtoimage.jpg),我该怎么做?

When editing an object that has an image field, you are presented with the current image path and the standard file upload field. What I want to do is to be able to replace the shown path(the "Currently: /pathtoimage.jpg" with the actual image. How do I do this?

感谢提前!

推荐答案

如果您在Django的管理员中谈论一个表单,您可以覆盖AdminImageWidget。

If you are talking about a form in Django's admin you could override the AdminImageWidget.

很少有片段和帖子解释细节:

There are few snippets and posts that explain the details:

  • Django simple admin ImageField thumbnail
  • ImageField for admin with thumbnail
  • Admin Image Widget

对于常规表单,您应该看看 django-form-utils

For regular forms you should take a look at django-form-utils:


这个应用程序提供实用程序
来增强D jango的表单处理:

This application provides utilities for enhancing Django's form handling:

一个ImageWidget,显示图片的缩略图,而不是
只是文件名。

An ImageWidget which display a thumbnail of the image rather than just the filename.

这篇关于Django - 删除“当前”在图像编辑表单中,并用实际图像替换它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆