Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6681491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:35:47+00:00 2026-05-26T04:35:47+00:00

I am building my first django app that uses user authentication and I’m using

  • 0

I am building my first django app that uses user authentication and I’m using
some examples I found on the web for reference. My examples use a method ‘direct_to_template’.
The problem is that I get a blank screen when I use this. I know that the
template is in my templates directory.

Why am I getting a blank screen at login? How can I fix this?

The examples I’m using:

  • Example #1: https://docs.djangoproject.com/en/dev/topics/auth/
    Example #2:
    http://www.nerdydork.com/django-login-form-on-every-page.html

My code is below:

————-base.html————-

Here is the trigger it's in the header bar.
<li><a href="/login">Log-In</a></li>

——— views.py ———————–

from django.template import Context, loader
from django.conf.urls import patterns, url, include
from django.views.generic.simple import direct_to_template
from django.http import HttpResponse

VER = "1a"  # Global I like to print; making sure my latest code is running.

def mylogin(request):
    print "mylogin called [%s] " % VER
    if request.method == 'POST':
    user = authenticate(username=request.POST['username'],
    password=request.POST['password'])
    if user is not None:
        if user.is_active:
            login(request, user)
            # success
            return HttpResponseRedirect('/')
        else:
            # disabled account
            return direct_to_template(request, 'inactive_account.html')
    else:
        # invalid login
        return direct_to_template(request, 'invalid_login.html')

# User just clicked login
#  *** I know this is getting called and I get a blank screen here ***
print "calling: direct_to_template('login.html')"
return direct_to_template(request, 'login.html')

def mylogout(request):
    print "mylogout called"
    logout(request)
    return direct_to_template(request, 'logged_out.html')

——— urls.py ———————–

from django.conf.urls import patterns, include, url
from django.views.generic.simple import direct_to_template
from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('',
    (r'^customers/$', 'jim.views.index'),
    (r'^customers/(?P<customer_id>\d+)/$', 'jim.views.detail'),
    (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/media'}),
    (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/static'}),
    (r'^login/$', 'jim.views.mylogin'),
    (r'^logout/$', 'jim.views.mylogout'),
    (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/media'}),
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    url(r'^admin/', include(admin.site.urls)),
)

urlpatterns += patterns('django.views.generic.simple', (r'^accounts/login/$', 'direct_to_template', {'template': 'login_required.html'}),
)

——— templates/login.html ———————–

{% if user.is_authenticated %}
    <!-- Authenticate account menu -->
{% else %}
    <h3>Login</h3>
    <form action="/login/" method="post" accept-charset="utf-8">
    <label for="username">Username</label><input type="text" name="username" value="" id="username" />
    <label for="password">Password</label><input type="password" name="password" value="" id="password" />
    <p><input type="submit" value="Login"></p>
    </form>
    {% endif %}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:35:47+00:00Added an answer on May 26, 2026 at 4:35 am

    Errr if your template is such

    {% if user.is_authenticated %}
        <!-- Authenticate account menu -->
    {% else %}
        stuff
    {% endif %}
    

    it seems pretty logical that your template is blank –_–

    further more.. 200 is not an HTTP error it means 200 OK: Standard response for successful HTTP requests.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Building my first web app using Yii and wondering if it is best to
I'm building my first django app. I have a user, and the user has
I'm building my first form with django, and I'm seeing some behavior that I
I am building a Django powered web app that has a large database component.
I'm building an app that notifies user when new ThreadedComments appear. For this I'm
I am learning Python and building my first web app. I have been going
I'm building my first CodeIgniter app - and have a registration form. I'm using
I'm building a web application (in Django) that will accept a search criteria and
I'm in process of building an app for Facebook using Python and Django. I'm
I'm building a Django app that needs to store multiple selected dates for an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.