I want to display the selected gallery in my admin. I’m not very capable of writing custom fields and couldn’t find any well documented guidelines about it.
As for my question, I’ve written basic classes such as:
class GalleryViewWidget(forms.TextInput):
def render(self,name,value,attrs):
rendered = super(GalleryViewWidget, self).render(name, value, attrs)
return rendered + mark_safe(....)
class ProductModelForm(forms.ModelForm):
information = forms.CharField(widget=forms.Textarea)
gallery = GalleryViewWidget
class Media:
css = {
'all': (settings.MEDIA_URL + 'css/preview.css',)
}
js=(
"http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js",
settings.MEDIA_URL + 'js/preview.js',
)
class Meta:
model = Product
In my preview.js file, I want to send an ajax request, the problem is I don’t know where to handle this ajax call. In my ProductModelForm ?
I’d really appreciate that if anyone gives me any knowledge about how to handle this ajax thing or another way to display selected gallery in my admin ?
Here I saw a bit outdated tutorial about it…
It creates your own thumbnails. You need to use “sorl-thumbnail” now-days for thumbnails generation and storing it’s a bit easier and more right way IMHO…
Nevertheless it’s a tutorial of how to build a photo previews in admin. You could use it or enhance it with AJAX calls. But IMHO again it’s not necessary…
P.S. It’s better to download full sources of this app from the start.
so… article:
Django Tutorial: Photo Organizer and Sharing App Part I. Enhancing Admin.