Hi I am trying to serve svg inline in a document rendered by a Django template where the svg ( 2D line drawings) and the document context are dynamically generated. The svg_string is put into my django context and rendered by the template.
{{ svg_string|safe }}
The django version I am using is 1.4.2 , Python version 2.7.3 .rdkit All my code works great when served at the permananent IP . The svg renders perfectly .
Now when I instead try to test the SVG containing view using the django (1.4.2) dev server http://127.0.0.1:8000
I get only the text labels in the svg rendered in Chrome,Firefox and Safari .
There is however one difference between the two svg. They are generated by different versions of the rdkit Cheminformatics library , which uses cairo in the backend.
The Production server served svg has the svg in view-source for html page as :
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="300pt" height="300pt" viewBox="0 0 300 300" version="1.1">
<defs>
<g>
<symbol overflow="visible" id="glyph0-0">
<path style="stroke:none;" d="M 0.40625 1.421875 L 0.40625 -5.640625 L 4.40625 -5.640625 L 4.40625 1.421875 Z M 0.84375 0.96875 L 3.953125 0.96875 L 3.953125 -5.1875 L 0.84375 -5.1875 Z "/>
</symbol>
<symbol overflow="visible" id="glyph0-1">
<path style="stroke:none;" d="M 0.78125 -5.828125 L 1.84375 -5.828125 L 4.4375 -0.953125 L 4.4375 -5.828125 L 5.203125 -5.828125 L 5.203125 0 L 4.140625 0 L 1.546875 -4.875 L 1.546875 0 L 0.78125 0 Z "/>
</symbol>
<symbol overflow="visible" id="glyph0-2">
<path style="stroke:none;" d="M 0.78125 -5.828125 L 1.578125 -5.828125 L 1.578125 -3.4375 L 4.4375 -3.4375 L 4.4375 -5.828125 L 5.234375 -5.828125 L 5.234375 0 L 4.4375 0 L
....
The dev server svg has a different structure when viewed as text and shows the following behavior: Renders in browser after saving it to file: Works. Renders in browser after forcing content-type to xhtml+xml : Works.
Does not render inline with default content-type . Only fonts are displayed.
The svg looks like
<svg:svg version="1.1" baseProfile="full"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xml:space="preserve" width="300px" height="300px" >
<svg:line x1="114.41" y1="132.42" x2="130.03" y2="146.44" stroke="rgb(0,0,0)" stroke-width="1"></svg:line>
<svg:line x1="113.56" y1="136.50" x2="126.06" y2="147.72" stroke="rgb(0,0,0)" stroke-width="1"></svg:line>
<svg:line x1="87.26" y1="137.68" x2="96.45" y2="142.94" stroke="rgb(0,0,255)" stroke-width="1"><
Sadly using xhmtl+xml breaks all my css and javascript ( bootstrap) and so is not workable.
Is there a way to have the inline svg as served by the rdkit library displayed above rendered in the dev server without using xhtml+xml content type?