Django Template does not exist error, although it shows 'file exists'

后端 未结 3 991
抹茶落季
抹茶落季 2020-12-10 07:26

I am not able to render any html pages in Django 1.7. My \'index.html\' is in \'project/seatalloc/templates/index.html\' and my view.py in proje

3条回答
  •  旧时难觅i
    2020-12-10 08:04

    First of all don't use static path (fixed path) in template dirs in settings.py, use:

    BASE_DIR = os.path.dirname(os.path.dirname(__file__))
    
    TEMPLATE_DIRS = (
          BASE_DIR +'/Templates',
    
    
      )
    

    And template directory should be in project directory i.e in which manage.py file exists.

    And in view.py use render_to_response instead of just render.

    return  render_to_response("index.html") 
    

提交回复
热议问题