Appropriate way to handle deprecated `adminmedia` templatetag and {

后端 未结 2 1762
忘掉有多难
忘掉有多难 2021-02-04 00:07

From django 1.5 onwards, https://docs.djangoproject.com/en/1.5/releases/1.5/#miscellaneous

The template tags library adminmedia, which only contained the

2条回答
  •  情书的邮戳
    2021-02-04 00:43

    Since Django 1.3 you can use django.contrib.staticfiles app.

    Make sure that django.contrib.staticfiles is included in your INSTALLED_APPS and the STATIC_ROOT and STATIC_URL options are specified in your settings.py.

    Then run manage.py collectstatic command and all applications' static files will be collected in STATIC_ROOT folder.

    In the templates you can use the {{ STATIC_URL }} context variable (make sure that django.core.context_processors.static is included in TEMPLATE_CONTEXT_PROCESSORS) or the {% static %} template tag.

    
    

    or

    {% load staticfiles %}
    
    

提交回复
热议问题