Module “django.core.context_processors” does not define a “auth” callable request processor

后端 未结 2 2003
花落未央
花落未央 2020-12-29 01:32

I have a Django live website , i want to do some kind of maintenance on it but when I downloaded it and tried to open it from my local machine and my debug mode is true I

2条回答
  •  佛祖请我去吃肉
    2020-12-29 01:46

    It looks like you have upgraded to Django 1.4 or later.

    The auth context processor has been moved from django.core.context_processors.auth to django.contrib.auth.context_processors.auth. The move started in Django 1.2, and django.core.context_processors.auth was completely removed in Django 1.4.

    I recommend you run the same version of Django on your dev and production environments to prevent errors like this.

    When you upgrade to Django 1.4, you need to make the following change to TEMPLATE_CONTEXT_PROCESSORS in your settings file:

    # old
    TEMPLATE_CONTEXT_PROCESSORS = ("django.core.context_processors.auth",
                                   ...
    )
    # new
    TEMPLATE_CONTEXT_PROCESSORS = ("django.contrib.auth.context_processors.auth",
                                   ...
    )
    

    When migrating, the release notes (1.2, 1.3, 1.4) are useful for catching changes like this.

提交回复
热议问题