Where is template context processor in Django 1.5?

后端 未结 2 1177
醉酒成梦
醉酒成梦 2020-12-09 09:12

Is it supposed to be listed in Settings.py automatically or do I have to add it? I am having a ridiculously hard time serving up an image file in development and the docs a

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-09 09:52

    You can check what context processors your app is using by jumping into the django python shell and importing your settings.

    $ manage.py shell
    > from django.conf import settings
    > settings.TEMPLATE_CONTEXT_PROCESSORS
    

    If you have not overridden them then the defaults should be rendered.

    On static files, check your STATICFILES_DIRS which is where django's development server will look to serve static assets: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-STATICFILES_DIRS.

    I use this in my settings.py:

    from os.path import join, abspath
    PROJECT_ROOT = abspath(join(dirname(__file__), '..', '..'))
    STATICFILES_DIRS = [join(PROJECT_ROOT, 'public'), ]
    

    This won't be the same for you as it will depend on how you layout your project.

提交回复
热议问题