Django太慢,并试图加载图像

时间:2014-01-31 10:22:56

标签: django performance static

我不知道为什么,但是django太慢而无法刷新页面(在我的本地开发服务器上)。我正在查看日志,它显示了很多次:

[31/Jan/2014 08:14:28] "GET /questoes/fisica/data:image/png;base64,iVBORw0KGgoAA
AANSUhEUgAAACIAAAAiCAYAAAA6RwvCAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllP
AAAA7dJREFUeNqsWM1PE0EU3+7ShdJKoTRA8UYgIUKM3rmaEI0euXsw0YMHIZEbxBijEiIHLkb/A44SD
YlXzkYPGBM+ri1NWz7aUmhp6+9tps10mLfdfrzkl2535r39zc77mvUdHh4abUoUCAD3xP/fQAFItWJkY
mLC+e1p8eGPgQcC08ycf8BPgW2vhr0SeQa8AWIe5k4LvATiwCrwtZmS2WT8IfAL+OKRhCoxoftH2GqLy
BLwHbhvdC53ha2lVrfmE/DKzbLP5yubplnt7e310f+rq6tqpVLxVatVy0VtHbgNLHohsupGIhQKFQG7v
79f+8CLiwsjl8sVAZsxQbYTwFrDwpTwpaj4ptPu6+vLDw4OBkHA014QobOzs3yhUAgyUx4BP2rhq/rIe
53GwMBAeXx83DMJEpobi8WCpMtMWeOc9TkwoyMRjUattrMedBkyM+KZN4isqDMDgUCuExIyGbKlGVpRi
Szo8kQ4HA4ZXRLGVuzo6GhBJjKviw6dT5TLZSOTyRinp6cGQrV+n67hnEY6nTaur6+1PkM2NWTm5fCd0
xDRhh89CKHpXCMijLGxMef6+PjYiRSSUqlUv6/arOlKMlcjQlV0qsGDTZPehpYIxurXRCSRSFByq5NQ5
6hvhWwj8cm2p7A9UdKYVBX8fn+F2+tIJGIgmzaQkUnYtm0MDw+zvsLYniQiEc2q/WxxwmqRHxrISA9xx
iyLDzTGdsRsJwJoK3QPo3vctnhpAzLqTexhiVOg6JAdU5bLy0vHZ+Ro8mg7Q0QO1LvwenZZJycnN3yCI
PsMRRYnjO0DU/SY+wprW7fiWmjKJMgnUIcafEaeoxZ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bLy0vHZ+Ro8mg7Q0QO1LvwenZZJycnN3yCI
PsMRRYnjO0DU/SY+wprW7fiWmjKJMgnUIcafEaeoxZCJWJI9lH4UjV2u6pSPp/XJR9jaGiIKrERDAbrj
llzYOQJZ4zm6ISxuSsntB3gqTyazWZtMowa0aBFb4HegC6aRkZG2C2hLSObmqEdOcVvUdJUZyBlZ7tVa
1ASdEUvjW3ZUqvvO82e3kqlUuVOSZANvBFd0fugawM2VKclOT8/tzohQ7pkgzn/rHNdvLbLJkPxeDzHR
RIXIaTDkCB57XacoJPZW8bZQpSskslk0Y0QjdEcmstsB8myegrsYbqmENfJU3dOpZyOEwjdCqLIWUyxW
KygVzHFccJ2eVkbar/qdq5ZFC3/R5dUb6EBsqQmyEtLuawj0eykRwpPgL0uRO+esLXW7tmX9nEWeAEk2
yCQFLqzzb4MeK3Zn4FRsapNEXqGy2eJTTF3VOh27bOE/Ia2pQ81YeCO+P+XknGrH2pq8l+AAQDv/n2Gm
q99BgAAAABJRU5ErkJggg== HTTP/1.1" 404 16622

查看时间戳!在简单的重新加载过程中差不多30秒......

有谁知道如何解决这个问题? 我认为它与staticserve / media文件有关......我认为这些文件是上传的...(我正在刷新一个用html内容编写的文章页面(所以这些文章有图像等)

非常感谢你!

UPDATING:

我的HTML视图:     {{question.statement | safe}}

我在循环中使用了上面的代码。 Statement是一个带有html内容的Text字段,如:

<p>Um laborat&oacute;rio realiza exames em que &eacute; poss&iacute;vel<br />observar a taxa de glicose de uma pessoa. Os resultados<br />s&atilde;o analisados de acordo com o quadro a seguir.</p> <p><img src="/media/uploads/questoes/individuais/9000000021%202014-01-31%2015.25.jpg" alt="" width="562" height="272" /></p> <p>Um paciente fez um exame de glicose nesse laborat&oacute;rio e<br />comprovou que estava com hiperglicemia. Sua taxa de glicose<br />era de 300 mg/dL. Seu m&eacute;dico prescreveu um tratamento em<br />duas etapas. Na primeira etapa ele conseguiu reduzir sua<br />taxa em 30% e na segunda etapa em 10%.</p> <p>Ao calcular sua taxa de glicose ap&oacute;s as duas redu&ccedil;&otilde;es, o<br />paciente verificou que estava na categoria de</p>

所以内容是指我上传到服务器的“/ media”图片。

在我的html布局中,我有一些带有静态标签的图像,比如(主要是布局目的):

{% static 'img/ico/icotop.png' %}

这是问题吗?

1 个答案:

答案 0 :(得分:1)

我认为在view.py中你将图像传递为没有mimetype的Httpesponse。还要尽量避免使用django来提供图像。 Apache / Web服务器可以非常快地为您处理这项工作..