转自:http://blog.csdn.net/xiaowanggedege/article/details/8651236

    django模板报错:

    Requested setting TEMPLATE_DEBUG, but settings are not configured.
    You must either define the environment variable DJANGO_SETTINGS_MODULE
    or call settings.configure() before accessing settings.

     

    好的解决办法:

    先导入settings

    >>> from django.conf import settings

    >>> settings.configure()

    >>> from django import template
    >>> t = template.Template('My name is {{ name }}.')
    >>> c = template.Context({'name': 'yixiaohan'})
    >>> print t.render(c)
    My name is yixiaohan.
    >>> c = template.Context({'name': 'xiaowangge'})
    >>> print t.render(c)
    My name is xiaowangge.

相关文章:

  • 2022-12-23
  • 2021-05-25
  • 2021-12-30
  • 2022-12-23
  • 2021-10-13
  • 2018-04-05
  • 2021-11-17
  • 2021-11-03
猜你喜欢
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案