在django中使用ImageField表单

时间:2011-05-26 19:10:24

标签: django django-forms

  

可能重复:
  Change default text in input type=“file”?

我想知道如何在django的ImageField表单中更改默认表单特征。这是我目前的情况 -

# in models.py
class Profile (models.Model):
    profile_picture = models.ImageField(upload_to='images/profile_picture',)

class ProfilePictureForm(ModelForm):
    class Meta:
        model = Profile
        fields = ('profile_picture',)

# in template
<form action="" method="post">{% csrf_token %}
    {{ form.profile_picture }}
    <input type="submit" value="Next Step", name='action'>
</form>

表单当前显示一个浏览按钮,其中显示表单的“选择文件”。

- 如何更改此按钮的值(例如,说“更改图片”)?

- 如何使用链接而不是按钮(例如,显示“Chnage Picture”的链接,单击时它与按钮的功能相同)? 谢谢。

0 个答案:

没有答案