I am creating a django application. Log in and display a static web page that the flatpages application manages.
Here are typical status messages from the dev server:
[15/Aug/2013 18:43:16] "GET / HTTP/1.1" 200 1263 [15/Aug/2013 18:43:23] "POST / HTTP/1.1" 302 0 [15/Aug/2013 18:43:23] "GET /home HTTP/1.1" 301 0 [15/Aug/2013 18:43:23] "GET /home/ HTTP/1.1" 200 4529
- The first line for the login page in /. This is successfully filed, code 200.
- The second line is the input of the form. The server response code is 302, which means the page is temporarily moving.
- The third line is an attempt to get a page ('/ home') that does not exist, because the main page is served by flatpages. Server response code 301 indicates that the page has been moved permanently.
- The fourth line is the successful delivery of content ('/ home') from flatpages.
Why is the server responding with request for request 302?
What causes the third line? Why is this message sent at all? Shouldn't that be something that middleware flatpages picks up on? Does my web client send a fourth line request? How does he know that?
I think the most important question is: am I doing something wrong?
Thanks for the help!
urls.py
urlpatterns = patterns('', url(r'^admin/', include(admin.site.urls)), url(r'^$', 'django.contrib.auth.views.login'), url(r'^logout$', 'guide.views.logout_view'),
views.py
def home(request): if request.user.is_authenticated() == False: return HttpResponseRedirect('/') return HttpResponseRedirect('/home/')
Excerpt from settings.py
MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', 'guide.middleware.LogActivity' ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.flatpages', 'django.contrib.admin', 'guide', )