[Solved] I keep getting ‘WSGIRequest’ object has no attribute ‘Get’ on django

I’m trying to build a little “boards” app for practicing purposes.
I’m currently stuck on a page, where a error occurs if I try to load a paginator template.

The error traceback looks like the following:

AttributeError at /board/2/
'WSGIRequest' object has no attribute 'Get'
Request Method: GET
Request URL:
Django Version: 1.7.6
Exception Type: AttributeError
Exception Value:    
'WSGIRequest' object has no attribute 'Get'
Exception Location: /home/web/workspace/simpleboard/board/views.py in read_board, line 38
Python Executable:  /home/web/venv/bin/python
Python Version: 3.4.2
Python Path:    

Traceback Switch to copy-and-paste view

/home/web/venv/lib/python3.4/site-packages/django/core/handlers/base.py in get_response
                response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
▶ Local vars
/home/web/workspace/simpleboard/board/views.py in read_board
page = request.Get.get("page") ...
▶ Local vars


def read_board(request, board_id):
    board = get_object_or_404(Board, id=board_id)
    article_list = board.article_set.order_by("-written_date")
    paginator = Paginator(article_list, 5)
    page = request.Get.get("page")           <--error here, apparently.

        articles = paginator.page(page)    
    except PageNotAnInteger:
        articles = paginator.page(1)    
    except EmptyPage:
        articles = paginator.page(paginator.num_pages)

    context = {
        "board" : board,
        "articles" : articles,
        "pages" : paginator.page_range

    return render(request, "board.html", context)


PS: tab key is not working on stackoverflow, so I had to indent with spaces instead. When I press tab, it jumps to “tags” box underneath. Does anyone know what the problem is? As far as I can remember, I worked fine last time. (I’m on Mac OS by the way.)

Enquirer: Bossam


Solution #1:

You have misprinted GET. Use:

page = request.GET.get("page")

Please read “Request and response objects” article on Django Docs.

Respondent: Bossam

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.