Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django - Remove "Currently" In An Image Edit Form and Replace It With The Actual Image

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?

Thanks in advance!

like image 857
yretuta Avatar asked Apr 19 '11 21:04

yretuta


People also ask

What is form Is_valid () in Django?

The is_valid() method is used to perform validation for each field of the form, it is defined in Django Form class. It returns True if data is valid and place all data into a cleaned_data attribute.


1 Answers

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

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

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

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

like image 83
arie Avatar answered Sep 20 '22 20:09

arie