'WSGIRequest' object has no attribute 'user' Django admin

后端 未结 8 1302
感动是毒
感动是毒 2020-11-29 01:08

When I trying to access the admin page it gives me the following error:

System check identified no issues (0 silenced).
June 21, 2016 - 15:26:14
Django versi         


        
8条回答
  •  半阙折子戏
    2020-11-29 01:51

    I had a similar error in my production server and thanks to sentry's breadcrumbs I saw that the error that was raising had to do with my settings, especially the ALLOWED_HOSTS.

    Django version 1.10.8 with python 2.7.

    My previous settings:

    ALLOWED_HOSTS = ['0.0.0.0',
                     'beta.mydomain.co.uk',
                     'mydomain.co.uk',
                     'www.mydomain.co.uk',
                     'alpha.mydomain.co.uk']
    

    Sentry Breadcrumbs screen shot:

    After that I looked around and found this:

    A value beginning with a period can be used as a subdomain wildcard: '.example.com' will match example.com, www.example.com, and any other subdomain of example.com.

    Link to Django official docs

    So my final settings that solved my problem:

    ALLOWED_HOSTS = ['0.0.0.0',
                     'mydomain.co.uk',
                     'www.mydomain.co.uk',
                     '.mydomain.co.uk']
    

    Hope this was useful :)

提交回复
热议问题