ImportError: Nenhum módulo chamado context_processors

4

Eu instalei a biblioteca django-paypal usando o pip, mas depois disso, minha versão original do django foi atualizada e, por causa disso, meu código em execução estava gerando um erro.

Então eu instalei o django-paypal. Mas ainda recebo o mesmo erro. O erro é

Import Error: No module named context_processors

Minha versão antiga do django é 1.8.7
Agora é atualizado para 1.10

Mensagens de erro:

Unhandled exception in thread started by <function wrapper at 0x7f7cb8032410>
Traceback (most recent call last):
  File "/home/v08/.local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/home/v08/.local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 121, in inner_run
    self.check(display_num_errors=True)
  File "/home/v08/.local/lib/python2.7/site-packages/django/core/management/base.py", line 385, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/v08/.local/lib/python2.7/site-packages/django/core/management/base.py", line 372, in _run_checks
    return checks.run_checks(**kwargs)
  File "/home/v08/.local/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/v08/.local/lib/python2.7/site-packages/django/core/checks/urls.py", line 14, in check_url_config
    return check_resolver(resolver)
  File "/home/v08/.local/lib/python2.7/site-packages/django/core/checks/urls.py", line 24, in check_resolver
    for pattern in resolver.url_patterns:
  File "/home/v08/.local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/v08/.local/lib/python2.7/site-packages/django/urls/resolvers.py", line 310, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/v08/.local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/v08/.local/lib/python2.7/site-packages/django/urls/resolvers.py", line 303, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/v08/django/FirstProject/FirstProject/urls.py", line 25, in <module>
    url(r'^', include('Car.urls')),
  File "/home/v08/.local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 50, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/v08/django/FirstProject/Car/urls.py", line 2, in <module>
    from . import views
  File "/home/v08/django/FirstProject/Car/views.py", line 7, in <module>
    from django.core.context_processors import csrf
ImportError: No module named context_processors
    
por Rohit Gavfale 05.08.2016 / 13:29

1 resposta

4

Setting.py para django1.8: - em TEMPLATES

            'django.template.context_processors.debug',
            'django.template.context_processors.request',
            'django.contrib.auth.context_processors.auth',
            'django.contrib.messages.context_processors.messages',
            'django.core.context_processors.i18n',
            'django.core.context_processors.media',
            'django.core.context_processors.static',
            'django.core.context_processors.tz',

Eu tenho o problema depois que as alterações devem ser feitas em setting .py file

Setting.py para django1.10: - em TEMPLATES

            'django.contrib.auth.context_processors.auth',
            'django.template.context_processors.debug',
            'django.template.context_processors.i18n',
            'django.template.context_processors.media',
            'django.template.context_processors.static',
            'django.template.context_processors.tz',
            'django.contrib.messages.context_processors.messages',

e altere em views.py : -

Código da versão 1.8: -

from django.core.context_processors import csrf
from django.core.context_processors import csrf

código da versão 1.10: -

from django.views.decorators import csrf
from django.views.decorators.csrf import csrf_protect
    
por Rohit Gavfale 05.08.2016 / 16:07

Tags