2

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.
0

1 Answer 1

6

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})
Sign up to request clarification or add additional context in comments.

3 Comments

(Also, its entirely possible that you may not need to import request at all)
Yeah I realised that. I wasn't done on the course.But I did with impulse. Works fine no! Thanks again!
@DevBingo - No worries, enjoy!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.