Home > Blockchain >  No module named 'django.core.context_processors' while I didn't use it anywhere
No module named 'django.core.context_processors' while I didn't use it anywhere

Time:03-03

This is my Views.py

    from django.shortcuts import render
    from .models import *


    def photoeditapp (request):
        if request.method == 'POST':
            imgmdl = ImageEditModel()
            img = request.FILES.get('img')
            imgmdl.imagename = 'sample1'
            imgmdl.image = img
            imgmdl.save()
    return render(request, 'photoedit.html')

Templates in settings.py

    TEMPLATES = [
{
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [
        os.path.join(BASE_DIR, 'templates'),
    ],
    'APP_DIRS': True,
    'OPTIONS': {
        'context_processors': [
            # '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.csrf',
        ],
    },
},

]

ERROR while running the server

    ModuleNotFoundError at /photoedit/
    No module named 'django.core.context_processors'

urls.py of the app

    urlpatterns = [
    path('photoedit/', views.photoeditapp, name='photoedit'),
    ]

I didn't use django.core.context_processors but it is till giving the error

CodePudding user response:

in your settings.py change

wrong:
   'django.core.context_processors.csrf',

correct:
    'django.template.context_processors.csrf',

the context_processors are no longer in core but in template

  • Related