Django and Bad Request (400)

蹲街弑〆低调 提交于 2019-12-03 19:22:35

It might be a bad Cookie. Try deleting them.

It looks like django can see if request isn't passed through dns server. Installation and configuration of bind9 instead of changes in /etc/hosts solved this problem.

You need another line in your hosts file.

127.0.0.1     localhost
127.0.0.1     my_site.com

Then in your ALLOWED_HOSTS...

ALLOWED_HOSTS = [
    'localhost',
    '.my_site.com', # not 'my_site.com'
]

ALSO, and this is probably important seeing as you are running your site from a virtual machine, when you run the site with python manage.py runserver, run it like this...

python manage.py runserver virtual.server.ip.address:8000

Obviously replace 'virtual.server.ip.address' with that virtual machines actual ip address.

Oleg Sivtsov

I print *DEBUG = None* and my django works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!