zoukankan      html  css  js  c++  java
  • AttributeError at /home/home/ Exception Type: AttributeError at /home/home/

    "错误提示信息":

    Environment:

    Request Method: GET Request URL: http://localhost:8000/home/home/

    Django Version: 1.7.5 Python Version: 2.7.0 Installed Applications: ('django.contrib.admin',  'django.contrib.auth',  'django.contrib.contenttypes',  'django.contrib.sessions',  'django.contrib.messages',  'django.contrib.staticfiles',  'home') Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware',  'django.middleware.common.CommonMiddleware',  'django.middleware.csrf.CsrfViewMiddleware',  'django.contrib.auth.middleware.AuthenticationMiddleware',  'django.contrib.auth.middleware.SessionAuthenticationMiddleware',  'django.contrib.messages.middleware.MessageMiddleware',  'django.middleware.clickjacking.XFrameOptionsMiddleware')

    Traceback:

    File "D:Python27libsite-packagesdjango-1.7.5-py2.7.eggdjangocorehandlersase.py" in get_response

      111.                     response = wrapped_callback(request, *callback_args, **callback_kwargs) File "D:Pythonweb estweblajihomeviews.py" in home

      5.     return render("templates/home.html", {}) File "D:Python27libsite-packagesdjango-1.7.5-py2.7.eggdjangoshortcuts.py" in render

      46.         context_instance = RequestContext(request, current_app=current_app) File "D:Python27libsite-packagesdjango-1.7.5-py2.7.eggdjango emplatecontext.py" in __init__

      209.             updates.update(processor(request)) File "D:Python27libsite-packagesdjango-1.7.5-py2.7.eggdjangocorecontext_processors.py" in debug

      40.     if settings.DEBUG and request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS:

    Exception Type: AttributeError at /home/home/

    Exception Value: 'str' object has no attribute 'META'

    《------------------------------错误原因-------------------------》

    views.py 中的返回值不正确

    def home(request):

        return render("templates/home.html", {})

    换成

    def home(request):
        #return render("templates/home.html", {})
        return render_to_response("home.html", {'song': 'Take me to your heart!'})

  • 相关阅读:
    YYHS-吴传之火烧连营(梦回三国系列T3)(trie树)
    YYHS-蜀传之单刀赴会(梦回三国系列T2)(最短路+状压dp)
    YYHS-魏传之长坂逆袭(梦回三国系列T1)
    BZOJ-2330-[SCOI2011]糖果(差分约束)
    BZOJ-1864-[Zjoi2006]三色二叉树(树形dp)
    YYHS-分数(二分+容斥)
    YYHS-猜数字(并查集/线段树维护)
    BZOJ-1225-[HNOI2001] 求正整数
    NOIP2014-飞扬的小鸟(DP)
    欧几里得距离、曼哈顿距离和切比雪夫距离
  • 原文地址:https://www.cnblogs.com/pyfreshman/p/4548030.html
Copyright © 2011-2022 走看看