need advice/tips on storing favicon in my django bookmark app

11 views
Skip to first unread message

Stephen Fox

unread,
Mar 16, 2017, 6:07:16 PM3/16/17
to Django users
I've developed a bookmark manager app in django. Things are working well. It's pretty cool, has a js bookmarklet and such. In my model I have fields such as link title, link category, link url, etc... I'd like to have an image as well.

So I was thinking of grabbing the favicon for the links and storing that as base64 in a CharField. Then pass that to the template and show an image along with the other link info.

I've had some issues however, I've tried messing with pyfav and just grabbing /favicon.ico and trying to encode to base64. I suppose I could also just point to {{ link.url }}/favicon.ico but not every site offers the favicon that way.

Just curious to see what other ideas someone has for offering an image to go along with my saved links.

Thanks

Antonis Christofides

unread,
Mar 17, 2017, 2:49:29 AM3/17/17
to django...@googlegroups.com

The favicon is pointed to inside the web page by an element such as this: <link rel="shortcut icon" href="...">. This is inside the <head>. To find the favicon you need to parse the HTML and locate the element. If you choose to download it and store it, the canonical way would be to use an ImageField.

Regards,

A.

Antonis Christofides
http://djangodeployment.com
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/705681e0-7050-44f7-ba8b-cc1ed66de7db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages