I get an error message:
'str' object has no attribute 'META'
Traceback highlights this bit of code:
return render('login.html', c)
Where is this bit of code located in my view.py:
from django.shortcuts import render
from django.http import HttpResponseRedirect
from django.contrib import auth
from django.core.context_processors import csrf
def login(request):
c = {}
c.update(csrf(request))
return render('login.html', c)
Here's what my template looks like:
{% extends "base.html"%}
{% block content %}
{% if form.errors %}
<p class = 'error'>Sorry, that not a valid username or password</p>
{% endif %}
<form action = '/accounts/auth/' method = 'post'> {% csrf_token %}
<label for = 'username'>User name: </label>
<input type = 'text' name = 'username' value = '' id = 'username'>
<label for = 'password'>Password: </label>
<input type = 'password' name = 'password' value = '' id = 'password'>
<input type = 'submit' value = 'login'>
</form>
{% endblock %}
I suppose that I might be misused render(), but in the docs I think I enter the correct parameters.
https://docs.djangoproject.com/en/dev/topics/http/shortcuts/
source
share