Python Django : No module named security

前端 未结 8 1900
迷失自我
迷失自我 2021-01-01 12:29

When I deploy my project on an Ubuntu Server, using a virtualenv, I got this error :

[17/Sep/2014 22:29:00] \"GET / HTTP/1.1\" 500 59
Traceback (most recent          


        
相关标签:
8条回答
  • 2021-01-01 12:52
    (myvenv) pip uninstall django==(version)
    (myenv) pip install django==(version)
    

    Just it.

    0 讨论(0)
  • 2021-01-01 12:55

    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.

    0 讨论(0)
  • 2021-01-01 12:55

    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',
    ]
    
    0 讨论(0)
  • 2021-01-01 12:57

    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 ?

    0 讨论(0)
  • 2021-01-01 13:08

    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.

    0 讨论(0)
  • 2021-01-01 13:09

    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.

    0 讨论(0)
提交回复
热议问题