TypeError : '모듈'개체는 Django 3 렌더링 함수를 호출 할 수 없습니다.

착암기 013

Django 3 응용 프로그램에서 간단한 hello world 페이지를 만들고 있는데 오류가 발생합니다.

TypeError: 'module' object is not callable

여기에 오류가 있습니다.

TypeError at /
'module' object is not callable
Request Method: GET
Request URL:    http://127.0.0.1:8000/
Django Version: 3.0.11
Exception Type: TypeError
Exception Value:    
'module' object is not callable
Exception Location: C:\Users\admin\AppData\Roaming\Python\Python37\site- packages\django\template\context.py in bind_template, line 246
Python Executable:  C:\Program Files (x86)\Microsoft Visual 
Studio\Shared\Python37_64\python.exe
Python Version: 3.7.8
Python Path:    
['C:\\Users\\admin\\Repositories\\django-docker\\django-portal-base\\app',
'C:\\Program Files (x86)\\Microsoft Visual '
'Studio\\Shared\\Python37_64\\python37.zip',
'C:\\Program Files (x86)\\Microsoft Visual 
Studio\\Shared\\Python37_64\\DLLs',
 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python37_64\\lib',
 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python37_64',
 'C:\\Users\\admin\\AppData\\Roaming\\Python\\Python37\\site-packages',
 'C:\\Program Files (x86)\\Microsoft Visual '
 'Studio\\Shared\\Python37_64\\lib\\site-packages']
 Server time:   Thu, 14 Jan 2021 19:15:32 +0000

이전에는 작동했지만 지금은 갑자기 작동하지 않습니다. 여기, 내 것이요views.py

from django.shortcuts import render
# from django.http import HttpResponse
# from django.template import RequestContext, loader
# from django.template import Context

def index(request):
    """Placeholder index view"""
    print('XXXX')
    return render(request, 'hello_world/index.html')
    #return HttpResponse('Hello, World!')

def test(request):
    context = {'foo': 'bar'}
    return render(request, 'hello_world/index.html', context) 

오류가 줄에 return render(request, 'hello_world/index.html')있지만 변경하면 return HttpResponse('Hello, World!')제대로 작동합니다.

내 HTML 파일은 매우 간단합니다. index.html

<h3> MY DJANGO APP</h3>

html 파일도 올바른 폴더에 있습니다. templates/hello_world/index.html

설정

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATES = [
{
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [os.path.join(BASE_DIR, 'templates')],
    'APP_DIRS': False,
    '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.contrib.sessions'
        ],
    },
},
]
xyres

django.contrib.sessions 호출 가능한 객체가 아니므로 유효한 컨텍스트 프로세서가 아닙니다.

실제로 앱이므로 INSTALLED_APPS목록이 아니라 TEMPALTES context_processors목록 에 있어야 합니다. 거기에서 제거하면이 문제가 해결됩니다.


왜 이런 일이 발생합니까?

예외는 django/template/context.py246 행 (Django v3.0.11)에서 발생한다고 언급합니다 . 246 번째 줄에 소스 코드가 보이면 이 줄에서 Django가 등록 된 템플릿 컨텍스트 프로세서를 실행하고 있음을 알 수 있습니다. , 이후 django.contrib.sessions호출 가능한 객체하지만 모듈 아니다,이 예외 메시지가 나타납니다 'module' object is not callable.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

'모듈'개체의 TypeError는 호출 할 수 없습니다.

분류에서Dev

Python / Pygame : TypeError : '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

Python TypeError : '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError : '모듈'객체는 Python3을 호출 할 수 없습니다.

분류에서Dev

Python 모듈 문제 : TypeError : '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError : 'Player'개체는 Django를 호출 할 수 없습니다.

분류에서Dev

Python timeit-TypeError : '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

Pytorch 1.7.0 | DataLoader 오류-TypeError : '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

/ api / register / '모듈'개체의 TypeError를 호출 할 수 없습니다.

분류에서Dev

EasyGUI 및 SimpleCV- TypeError : '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

django-selenium TypeError : 'str'개체를 호출 할 수 없습니다.

분류에서Dev

Django Rest Framework에서 '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

렌더링하는 동안 TypeError 발생 : 'int'개체는 django 템플릿에서 반복 할 수 없습니다.

분류에서Dev

TypeError : '모듈'객체는 Spacy Python에서 호출 할 수 없습니다.

분류에서Dev

TypeError 'bool'객체는 django에서 호출 할 수 없습니다.

분류에서Dev

pygame '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError : 'bool'개체는 함수 호출을 위해 호출 할 수 없습니다.

분류에서Dev

TypeError : 'int'객체는 Python 3을 호출 할 수 없습니다.

분류에서Dev

TypeError : 'NoneType'개체는 CircleCI를 호출 할 수 없습니다.

분류에서Dev

TypeError : 'str'개체는 MySQL에서 호출 할 수 없습니다.

분류에서Dev

TypeError at / 'SimpleLazyObject'개체는 호출 할 수 없습니다.

분류에서Dev

모델 적합 / TypeError : 'NoneType'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError : uwsgi / nginx를 사용하여 플라스크 앱을 배포하는 동안 '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

Django TypeError 튜플 객체를 호출 할 수 없습니까?

분류에서Dev

TypeError : '_IncompatibleKeys'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError : 'CurrencyConverter'개체를 호출 할 수 없습니다.

분류에서Dev

firebase = firebase (config) TypeError : 'module'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError : '목록'개체를 호출 할 수 없습니다-assertWarns ()

Related 관련 기사

  1. 1

    '모듈'개체의 TypeError는 호출 할 수 없습니다.

  2. 2

    Python / Pygame : TypeError : '모듈'개체를 호출 할 수 없습니다.

  3. 3

    Python TypeError : '모듈'개체를 호출 할 수 없습니다.

  4. 4

    TypeError '모듈'개체를 호출 할 수 없습니다.

  5. 5

    TypeError : '모듈'객체는 Python3을 호출 할 수 없습니다.

  6. 6

    Python 모듈 문제 : TypeError : '모듈'개체를 호출 할 수 없습니다.

  7. 7

    TypeError : 'Player'개체는 Django를 호출 할 수 없습니다.

  8. 8

    Python timeit-TypeError : '모듈'개체를 호출 할 수 없습니다.

  9. 9

    Pytorch 1.7.0 | DataLoader 오류-TypeError : '모듈'개체를 호출 할 수 없습니다.

  10. 10

    / api / register / '모듈'개체의 TypeError를 호출 할 수 없습니다.

  11. 11

    EasyGUI 및 SimpleCV- TypeError : '모듈'개체를 호출 할 수 없습니다.

  12. 12

    django-selenium TypeError : 'str'개체를 호출 할 수 없습니다.

  13. 13

    Django Rest Framework에서 '모듈'개체를 호출 할 수 없습니다.

  14. 14

    렌더링하는 동안 TypeError 발생 : 'int'개체는 django 템플릿에서 반복 할 수 없습니다.

  15. 15

    TypeError : '모듈'객체는 Spacy Python에서 호출 할 수 없습니다.

  16. 16

    TypeError 'bool'객체는 django에서 호출 할 수 없습니다.

  17. 17

    pygame '모듈'개체를 호출 할 수 없습니다.

  18. 18

    TypeError : 'bool'개체는 함수 호출을 위해 호출 할 수 없습니다.

  19. 19

    TypeError : 'int'객체는 Python 3을 호출 할 수 없습니다.

  20. 20

    TypeError : 'NoneType'개체는 CircleCI를 호출 할 수 없습니다.

  21. 21

    TypeError : 'str'개체는 MySQL에서 호출 할 수 없습니다.

  22. 22

    TypeError at / 'SimpleLazyObject'개체는 호출 할 수 없습니다.

  23. 23

    모델 적합 / TypeError : 'NoneType'개체를 호출 할 수 없습니다.

  24. 24

    TypeError : uwsgi / nginx를 사용하여 플라스크 앱을 배포하는 동안 '모듈'개체를 호출 할 수 없습니다.

  25. 25

    Django TypeError 튜플 객체를 호출 할 수 없습니까?

  26. 26

    TypeError : '_IncompatibleKeys'개체를 호출 할 수 없습니다.

  27. 27

    TypeError : 'CurrencyConverter'개체를 호출 할 수 없습니다.

  28. 28

    firebase = firebase (config) TypeError : 'module'개체를 호출 할 수 없습니다.

  29. 29

    TypeError : '목록'개체를 호출 할 수 없습니다-assertWarns ()

뜨겁다태그

보관