Auto redirect with Apache?

30 views
Skip to first unread message

Andrea Angelini

unread,
Dec 11, 2015, 8:52:45 AM12/11/15
to Django users
I'm experiencing this problem since recently, I guess after upgrading to Django 1.9.
I had originally this problem with DRF
https://github.com/tomchristie/django-rest-framework/issues/3724
but I adapted it to Django.

With the following code I can reproduce the problem. The problem happens with Apache and not with the built-in Django web server.

    from __future__ import unicode_literals

    from django.views.generic import View
    from django.http import HttpResponse

    class Test200(View):
        def get(self, request, *args, **kwargs):
            response = HttpResponse(status=200)
            response['Location'] = '/'
            return response

    class Test202(View):
        def get(self, request, *args, **kwargs):
            response = HttpResponse(status=202)
            response['Location'] = '/'
            return response

[...]

    url(r'^test200/$', Test200.as_view()),
    url(r'^test202/$', Test202.as_view()),

With the Django built-in server, I get the correct status code and no content in both cases.
With Apache on production I get nothing from the second view, meanwhile from the first view I get the content of the main page (that is the content of "/") even if the URL remains "/test200/".
Can someone reproduce the problem? Is it an Apache misconfiguration?

Thanks,
Andrea
Reply all
Reply to author
Forward
0 new messages