First of all I have done my research and found no reasonable explanation 
for my issue. I have a site on heroku that works fine on the first page, 
but when I click a button that I have programmed to go to another page, I 
obtain the infamous CSRF error. The reason for this error is CSRF cookie is 
not set. Here is a description of the background work done on the dev side:

1. Settings.py

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',    
    #'django.middleware.security.SecurityMiddleware',
     'django.middleware.csrf.CsrfViewMiddleware',
)

2. base.py

<form class="col-lg-12" method = "post" id="loginform" action= "/menu/"> 
            {% csrf_token %}

            <div class="input-group" style="width: 
65%;0px;text-align:center;margin:0 auto;">
            <input class="form-control input-lg" title="Don't worry. We 
hate spam, and will not share your email with anyone." placeholder="Email 
address" type="text">              
            </div>
            <br>
            <div class="input-group" style="width: 
65%;0px;text-align:center;margin:0 auto;">
              <input class="form-control input-lg" title="Don't worry. We 
hate spam, and will not share your email with anyone." 
placeholder="Password" type="text">
            </div>   
            <br>
            <br>       

            <button class="btn btn-lg btn-primary" style = "width: 100px" 
type="button" onClick ="logIn();">Log In</button>

            <br><br>

          </form>

3. views.py

def menu(request):

    return render_to_response('home/base_1.html', context_instance = 
RequestContext(request, {}) )

4. javascript for the function logIn() that is executed when the button is 
clicked from (2)


function logIn ()
{
    alert('Form has been submitted');
    document.getElementById('loginform').submit();
}

I am seriously bewildered and cannot understand why the base_1.html site is 
not being rendered and I am getting this CSRF error ! Please help me,





-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e016d6f9-875e-4f51-a6cb-b38a6cda2a73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to