jazzband / jazzband/django-floppyforms

issue in ImageThumbnailFileInput in django forms

Open
#142 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
836
Forks
150
PR merge metrics
No merged PRs in 30d

Description

i am using django-floppyforms in my project
but it can't get preview image in template
i folow example from
http://django-floppyforms.readthedocs.org/en/latest/examples.html#an-image-clearable-input-with-thumbnail

my forms.py

``` python
from django import forms
import datetime
from .models import Product
from hvad.forms import TranslatableModelForm
from ajax_upload.widgets import AjaxClearableFileInput
from django.utils.translation import ugettext_lazy as _
from crispy_forms.helper import FormHelper
from crispy_forms import layout, bootstrap
from crispy_forms.helper import FormHelper
#from crispy_forms.layout import Layout, Fieldset, ButtonHolder, Submit, HTML

from floppyforms import ClearableFileInput
import floppyforms as forms

class ImageThumbnailFileInput(forms.ClearableFileInput):
template_name = 'floppyforms/image_thumbnail.html'

class ProductForm(TranslatableModelForm):
class Meta:
model = Product
fields = ('product_name','category','pro_image1','pro_image2','pro_image3','pro_image4','price','negotiable','des','dis_code')
widgets = {'pro_image1': ImageThumbnailFileInput,
'pro_image2': ImageThumbnailFileInput,
'pro_image3': ImageThumbnailFileInput,
'pro_image4': ImageThumbnailFileInput,
}
```

my "models.py "

``` python
pro_image1 = models.FileField(upload_to='products/',blank=True, null=True, verbose_name = _('Product Image1')),
pro_image2 = models.FileField(upload_to='products/',blank=True, null=True, verbose_name = _('Product Image2')),
pro_image3 = models.FileField(upload_to='products/',blank=True, null=True, verbose_name = _('Product Image3')),
pro_image4 = models.FileField(upload_to='products/',blank=True, null=True, verbose_name = _('Product Image4')),

```

image_thumbnail.html

```
{# image_thumbnail.html #}
{% load i18n %}
{% if value.url %}{% trans "Currently:" %} {{ value }}
{% if not required %}


{% trans "Clear" %}


{% else %}

{% endif %}
{% trans "Change:" %}
{% endif %}

```

i also try with imagefields in models.py
how can i solve this ,
Pls help!!!

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the form rendering described in forms.py with the model fields in models.py, then compare the result with the linked floppyforms thumbnail example. Inspect image_thumbnail.html and verify whether the submitted image value exposes the expected URL; done means an existing image preview renders in the template.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.