Store base64 data in database with imagefield ?

777 views
Skip to first unread message

bussiere bussiere

unread,
May 15, 2012, 7:55:05 AM5/15/12
to django...@googlegroups.com
Does anyone tried to store only Base64 info in databse of an image
instead of a file with django image field ?

Do you have any idea how to do it ?

Or some hints to give me ?

regards and thanks
Bussiere



"Les nouvelles technologies offrent pleins de nouvelles possibilités,
pleins de possibilités d'erreurs surtout en fait."
insurance.aes256 : http://goo.gl/gHyAY
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.7.96rc1

mQGiBE9sjdsRBADsY+DaDgj+pDuGLNVL6Dc+ghCxaEBK+9nwBvKPGIUocz13V42P
5Jn/NJ9zRgZNdg5XbhohN2ltas8Nr09rrRQXbBk8zjCg/Qr0a4LmfA3j128SwCfZ
aTe5zlo/WSSuGv6kWGe/KZrLmiQoZRTDbZzqWyZxuJRkcpgsZc+jYRXJHwCgualT
LpC23Ja3plM6J6noFaqAlMUEAKZGDadSS/BW4gckw9XqSHRex7/XyWU4sqVQlhMy
5DEIba7H8cU6grww+p/cYa3OCocv5Mycf6MbWDCPrtsG0X08u8PgEaE29BsLIgSm
JF6r8y4Rgwj5xyCMTaxql82S+tZHyScpAoQ0a+xlTwxMZMuwK9p6b7oipXHL+UPN
sDfkBACoYLS4PQPFotqWI96j83NNLwEumUzA6Rqyas8w6Xwr51quA65y/0nBmMmp
l58tKN7eyc5+bIpRX5bGG6ktCUHnfzk9uvnG7peilWzYT6+AJ3gbBgMGLBPByJBN
NH+nLjzsh4PzIxuSHLMiK5FkDNE2B95kaahIg42SQPT80LyvDLQlYnVzc2llcmVf
cHJpdmF0ZSA8YnVzc2llcmVAZ21haWwuY29tPohZBBMRAgAZBQJPbI3bBAsHAwID
FQIDAxYCAQIeAQIXgAAKCRAYpzZWoPP7b0h0AJ4n9feBF2FH4JUGhLU3XL3eIrOX
9gCfZbN4JHYl/nRLL4uHrceRUk1M9Pm5Ac0ET2yN3hAHAK5MypLMT50yklt1n/pQ
MjrFXuvM9IQvVyQemHMUBqKqxPTVMJLn86mR5mTLMqs+WVAqei8GTsQeSSvHyIbk
8RvYrKY7aK2RVZUV1dHQ6PII0w3BI5C0L9GM/UyIq0VRXTW6zjp9hS/xgn5SrQad
VIdGQKFVJa9h5/AzgjseARMQRkTQA/xX5/WmHxXaXUPhGxCeFsoqs53UFz1rkHYx
mus2WiD0gHbJ58DiMlVmupeNumi4e9wa+mYuW4qGwjzsQn9ZFNdoiUFzQrqZa6o+
Son+yZpGe/H9VidrWR5LhwD7AAMGBv9bhswvwpQ23X0kGItv7/jHVr/RJui7FAXY
mOM4WAoUv/5ttPHf8OifWmeUDPlzm4txvR5a7t4hhVDehek1J7FEVvfG+ffcHiPP
kkFaUv2EgrXziozt/Vkr2nngsKO5FpRJe9GSqn68uZirhwbkHSKX6LPNFTWSYR3E
fefnsCaP82OJDBFGFMg2aMsz9QL85bg58fgHU972kLTePXUVAh3gaxb6qpjwZt2b
yrCGJ/rnmIc/IWH8TJtHI5Yf3Abx2vlFTtzRH0CwVXuO0msjcfRrrrrS8NSm/ih5
0ssElxKU6IhGBBgRAgAGBQJPbI3eAAoJEBinNlag8/tvoBEAn2Yqu0UFC5OSjD1Y
JQ00FFjNVestAJ0XctcbmhKaFuQ46SccW8C2JDG/xA==
=+VZi
-----END PGP PUBLIC KEY BLOCK-----

Nikhil Verma

unread,
May 15, 2012, 8:06:34 AM5/15/12
to django...@googlegroups.com
Hi

I had similar situation where a textfield (which was made a markup editor by applying css and all) was given where people come in write anything and discuss about their topics; you can imagine like a forum.
So i made some regular expressions to allow videos to show in an iframe and image to open up in a fancy box.
Your case is similar to my case where image has to be shown in a fancy box when a user clicks on that.


So i had to use jquery like this:-

Step 1) Write the importing scripts line in base.html

Step 2) Textfield which i was showing  on templates put a class and then call this jquery. Luckily that solved my problem
<script>
$(document).ready(function(){
    $("a.fancybox").fancybox({type:'image'});
});
 </script>

Hope that helps you.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.




--
Regards
Nikhil Verma
+91-958-273-3156

Frank Stüss

unread,
May 15, 2012, 9:00:59 AM5/15/12
to django...@googlegroups.com
Hi,
maybe you could use http://djangosnippets.org/snippets/1669/

Greetings
> +unsub...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>
>
> --
> Regards
> Nikhil Verma
> +91-958-273-3156
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users
> +unsub...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

--
Armaturen und Fittings Stüss e.K.
Frank Stüss + Inhaber
Tel. +49+6187-5019 + FAX. +49+6187-91725
Kilianstädter Straße 25 + D-61137 Schöneck
email frank....@stuess.de <http://www.stuess.de>
Sitz Schöneck, HRA5340, Amtsgericht Hanau
USt.-ID: DE252310440

............................................
Fördermitglied der Wirtschaftsjunioren
Hanau-Gelnhausen-Schlüchtern
Umfassende Infos: http://www.wj-hanau.de
Senator #68128


Hutch

unread,
May 15, 2012, 5:57:31 PM5/15/12
to django...@googlegroups.com
are you sure this is actually a good idea?

in almost all cases serving the image via the actual web server, whose job it is to serve images, is the best idea.

either way, you wouldn't use an image field to store base64 data. that's for references to actual files in a filesystem.

first you'd need to convert the image to base64. then store that in a textfield. keep in mind there's going to be size limits with that.

i'd read:
https://docs.djangoproject.com/en/1.4/topics/http/file-uploads/ if you're dealing with uploads from a client's browser
otherwise just standard file objects will work
and then



re: nikhil, i'm not sure how jquery or any of that is relevant,

bussiere bussiere

unread,
May 16, 2012, 9:19:29 AM5/16/12
to django...@googlegroups.com
Thanks all

But there is nothing to do it from imagefield directly ?
Because if someone use the admin interface ?
(mayber i've misread what you gave).

regards
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/8vn8tqb-nrwJ.
>
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages