Reputation: 67
I got this error, but I've done exactly the same:
AttributeError at /courses/ module 'django.http.request' has no attribute 'META'
The error is occuring in :
from django.shortcuts import render
from django.http import request
from django.http import HttpResponse
from .models import Course
# Create your views here.
def course_list(response):
courses = Course.objects.all()
return render(request, 'courses/course_list.html',{'courses':courses})
# output=', '.join([str(course) for course in courses])
# return HttpResponse(output)
But the server shows no issues at all.
Performing system checks...
System check identified no issues (0 silenced).
September 13, 2016 - 13:51:18
Django version 1.10.1, using settings 'learning_site.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Upvotes: 2
Views: 10252
Reputation: 43300
Your function parameter is called response
but then you use request
which is a module you import, change the field param to be called request
or change its usage inside the function to be response
def course_list(request):
courses = Course.objects.all()
return render(request, 'courses/course_list.html',{'courses':courses})
def course_list(response):
courses = Course.objects.all()
return render(response, 'courses/course_list.html',{'courses':courses})
Upvotes: 6