How to remove the “Currently” tag and link of a FileInput widget in Django?

三世轮回 提交于 2019-12-22 05:24:19

问题


I made a ModelForm from a Model in Django, the model have an ImageField field on it. When I render the info of the form in a template for editing it, it show this:

How I can remove the 'Currently' tag and link??


回答1:


The Django Admin uses AdminFileWidget to render ImageFields. AdminFileWidget merely inherits from the standard FileInput widget and adds the extra "Currently" stuff. So just use FileInput instead:

from django.db import models
from django import forms

class MyModelAdmin(admin.ModelAdmin):
    formfield_overrides = {
        models.ImageField: {'widget': forms.FileInput },
    }


来源:https://stackoverflow.com/questions/6076154/how-to-remove-the-currently-tag-and-link-of-a-fileinput-widget-in-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!