Error with the commandant runnerver of Django

0

Trying to run the local Django server I get the following error in the terminal when running using runserver.

This is the message:

    System check identified no issues (0 silenced).
February 28, 2016 - 15:50:27
Django version 1.7.9, using settings 'guacho.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/usr/lib/python2.7/dist-packages/django/contrib/staticfiles/handlers.py", line 64, in __call__
    return self.application(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 168, in __call__
    self.load_middleware()
  File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 44, in load_middleware
    mw_class = import_string(middleware_path)
  File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 26, in import_string
    module = import_module(module_path)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named security
[28/Feb/2016 15:50:40] "GET / HTTP/1.1" 500 59

Why does this happen? How can I fix it and prevent it from happening again?

    
asked by G. Michel 28.02.2016 в 21:18
source

2 answers

3

What I think is happening is that you are using version 1.7.9 of Django to run a Django project created with version 1.8, in this version django I add the middleware ‘django.middleware.security.SecurityMiddleware’

Here I leave you 2 alternatives

  • Use a version of django greater than or equal to 1.8 (> = 1.8) , to install the latest version use pip install django , and to install to a specific version pip install django == 1.8 .

  • Delete ‘django.middleware.security.SecurityMiddleware’ of the MIDDLEWARE_CLASSES variable in settings.py

  • answered by 07.03.2016 в 01:10
    1

    If I'm not wrong, the module that is not in the project is:

    django.middleware.security.SecurityMiddleware

    SecurityMiddleware was added in Django 1.8 , so try an equal or greater version, or delete it from settings.py if you should definitely stay in Django 1.7 .

        
    answered by 28.02.2016 в 21:36