Last active
December 15, 2015 04:59
-
-
Save zhasm/5206108 to your computer and use it in GitHub Desktop.
font awesome 在firefox 下不能正常显示。搜索到基于 apache .htaccess 的解决方案(http://is.gd/3UrgIp),于是写出对应的django 解决方案。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#urls.py | |
url(r'^media/font/(?P<font>.*(?:eot|ttf|oft|woff))$', views.font, name='font'), | |
#views | |
import os | |
from django.conf import settings | |
def font(request, font): | |
font_fn = os.path.abspath(os.path.join(settings.MEDIA_ROOT, 'font/%s' % font)) | |
if os.path.exists(font_fn): | |
return HttpResponse(open(font_fn).read(), 'font/otf') | |
else: | |
return HttpResponse('', 'font/otf') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment