正如标题所示,在safari上访问我的网站时,会下载网页而不是正常呈现。它在chrome和firefox上很好用。我怀疑这是redirect
的原因,因为当没有重定向时它正在使用safari。 /admin
在safari中运行良好。请帮忙。
在root / urls.py中
urlpatterns = patterns(
'',
url(r'^admin/', include(admin.site.urls)),
url(r'^$', RedirectView.as_view(url='/albums/latest/', permanent=True)),
url(r'^albums/', include('photography.urls')),
)
在app / urls.py 中
urlpatterns = patterns(
'photography.views',
url(r'^latest/$', views.latest_album),
url(r'^(?P<slug>[a-zA-Z0-9-]+)/$', views.photos_by_location,
name='photos_by_location'),
)
和views.py
def latest_album(request):
context = RequestContext(request)
try:
latest_album = Album.objects.latest('id')
except Album.DoesNotExist:
raise Http404("Didnt find any Album matches the query.")
photos = get_list_or_404(Photo, album=latest_album)
context_dict = {}
context_dict['album'] = latest_album
context_dict['photos'] = photos
return TemplateResponse(request, 'photography/photos_by_location.html',
context_dict, context)
有关我的服务器的更多信息:
HTTP/1.1 301 MOVED PERMANENTLY
Connection: keep-alive
Content-Type: text/html; charset=utf-8
Date: Thu, 03 Sep 2015 22:58:36 GMT
Location: http://joyceful.com/albums/latest/
P3P: CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"
Server: nginx/1.4.6 (Ubuntu)
Transfer-Encoding: chunked
X-Frame-Options: SAMEORIGIN
答案 0 :(得分:0)
将TemplateResponse
更改为render_to_response
解决了问题。不知道为什么会这样。