46👍
I met the same problem. Finnaly, I found I’m using django 1.7.1 to run a 1.8dev generated project. When I switch back to 1.7.1, and remove ‘django.middleware.security.SecurityMiddleware’ in setting.py, it seems ok.
12👍
So, I found a solution :
'django.middleware.security.SecurityMiddleware'
This line is in MIDDLEWARE_CLASSES, from settings.py.
When I delete this line I have no more problems with the security module but I guess this is not a good way to solve the problem … I guess this line is in relation with the crsf token and things like that.
Any other idea to fix the problem ?
- [Django]-Django Rest Framework Token Authentication
- [Django]-Django return file over HttpResponse – file is not served correctly
- [Django]-Manually create a Django QuerySet or rather manually add objects to a QuerySet
8👍
I ran into this same problem. It turned out that I was inadvertently using my machine’s version of django-admin.py to start my Django project, rather than the one installed within the virtualenv. I ended up having to source bin/activate
again after installing django within the virtualenv, before running any of the django-admin commands.
- [Django]-Where is a good place to work on accounts/profile in Django with the Django registration app?
- [Django]-Printing Objects in Django
- [Django]-Django FormView vs CreateView
1👍
I had the same problem when switching my project from another pc. As i didn’t like very much the option given to remove the
‘django.middleware.security.SecurityMiddleware’
I just created a new project and a new app, change the settings by hand and copy the rest of the files, and it worked 🙂
I’m guessing it has something to do with the secretkey of the project.
- [Django]-Is there a built-in login template in Django?
- [Django]-Django MySQL full text search
- [Django]-Assertion error at: Django-rest-Framework
1👍
If you previously used a virtualenv for this project make sure that you activate it for the next time that you will use this project source bin/activate
or check to see that you use the proper version of django
.
If you want to remove some middlewares then you need to make sure of what you are doing.
- [Django]-Why isn't assertRaises catching my Attribute Error using python unittest?
- [Django]-Access django model fields label and help_text
- [Django]-Understanding ManyToMany fields in Django with a through model
0👍
use this it worked for me
MIDDLEWARE_CLASSES = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
- [Django]-Raise a validation error in a model's save method in Django
- [Django]-How to query as GROUP BY in Django?
- [Django]-How to expire session due to inactivity in Django?
0👍
I guess this happen in django version 1.7.x when you are trying to open project created using django version higher than 1.7.x
removing 'django.middleware.security.SecurityMiddleware'
helps but it create another problem 'session error'
or something
to fix this:
pip uninstall django==1.7.x //your current version of django installed
pip install django==1.9.x //or version that is compatible with the project
- [Django]-Can to_representation() in Django Rest Framework access the normal fields
- [Django]-Django – how do I select a particular column from a model?
- [Django]-ImportError: bad magic number in 'time': b'\x03\xf3\r\n' in Django
-2👍
(myvenv) pip uninstall django==(version)
(myenv) pip install django==(version)
Just it.
- [Django]-How to handle per object permission in Django nowadays?
- [Django]-Django, filter by specified month and year in date range
- [Django]-How can I use the variables from "views.py" in JavasScript, "<script></script>" in a Django template?