SVG and Django

1,175 views
Skip to first unread message

claytonbonelli

unread,
Oct 16, 2009, 7:54:56 AM10/16/09
to Django users
I have a HMLT file with a SVG embed tag, like this:

<html>
<head></head>
<body>
<div>
<embed src="radial2.svg" width="100%" height="100%"
type="image/svg+xml"
pluginspage="http://www.adobe.com/svg/viewer/install/"
/>
</div>
</body>
</html>

This file works fine when I opened it with firefox, but dont work if
the file is served by django server. The SVG image (radial2.svg) is
not displayed.

Any help?

Thanks

Clayton

wancharle sebastiao quirino

unread,
Oct 16, 2009, 8:34:07 AM10/16/09
to django...@googlegroups.com
try accessing the url http://127.0.0.1:8000/radial2.svg in firefox and see what happens.

Probably you have not set the right url for static files.


2009/10/16 claytonbonelli <cla...@unisul.br>

Tim Chase

unread,
Oct 16, 2009, 8:35:04 AM10/16/09
to django...@googlegroups.com
> <html>
> <head></head>
> <body>
> <div>
> <embed src="radial2.svg" width="100%" height="100%"
> type="image/svg+xml"
> pluginspage="http://www.adobe.com/svg/viewer/install/"
> />
> </div>
> </body>
> </html>
>
> This file works fine when I opened it with firefox, but dont work if
> the file is served by django server. The SVG image (radial2.svg) is
> not displayed.

Is this the production server or the dev server? Assuming the
SVG file is just more static media, so you'll want to read up on
that. If it's the production server, make sure that you have it
serving the static media instead of handing it off to Django. If
it's the development server, make sure that you're serving static
files. I usually do this with something like

if 'runserver' in argv:
urlpatterns += patterns('',
(r'^site_media/(?P<path>.*)$',
'django.views.static.serve',
{'document_root': '../media'}
),
)

in my urls.py so that when I use the dev server, it also handles
static media.

If the SVG is dynamically created (yay, SVG!), make sure your
urls.py can find it and that you point to an appropriate view.

-tim

claytonbonelli

unread,
Oct 16, 2009, 3:35:37 PM10/16/09
to Django users
Thanks,

The SVG file AND the image files are on the same location (production
server), and that location works fine. The image file is displayed on
my html page, but the SVG file dont.

Javier Guerra

unread,
Oct 16, 2009, 4:43:54 PM10/16/09
to django...@googlegroups.com
On Fri, Oct 16, 2009 at 2:35 PM, claytonbonelli <cla...@unisul.br> wrote:
> The image file is displayed on
> my html page, but the SVG file dont.

maybe some mime-type configuration missing?


--
Javier

Bayuadji

unread,
Oct 16, 2009, 6:42:50 PM10/16/09
to django...@googlegroups.com
Perhaps also should set some response headers to svg type?
--
--------------------------------------------------------------
http://www.tumbletooth.org
my linkedin profile : http://www.linkedin.com/in/bayuadji
--------------------------------------------------------------
Reply all
Reply to author
Forward
0 new messages