font-face not working in django

In django (local test project) I have my style.css file in a static folder which is works perfect and style applies to template. static folder contain an image folder and a fonts folder. The content of image folder appear in browser but the fonts not!!! here is my font-face code:

font-family: '‌‌‌BMitra';
src: url('fonts/BMitra.eot?#') format('eot'),
url('fonts/BMitra.ttf') format('truetype'),
url('fonts/BMitra.woff') format('woff');

I check css by firebug and find my personal font is disable and browser uses tahoma instead:

direction: rtl;
color: #092E20;
font-size: 24px;
font-family: BMitra, Tahoma, Arial;
text-align: right;

how do you use font-face in django?


As you have mentioned you directory structure is:

  • static
    • css
      • my_css_file.css
    • fonts
      • font1
      • font2

Then in your my_css_file.css file you need to step up one folder to access fonts:

url('../fonts/BMitra.ttf')

So just in case anyone is still running into this problem, I couldn't find an answer anywhere else. Inside the CSS it won't work using relative paths, only through the absolute path starting from the static folder, like so:

src: url('/static/fonts/BMitra.eot?#') format('eot'),