我看不到图像。所以请帮助我。我正在使用 django 模板

问题描述 投票:0回答:1

i am unable to get pictures.

我已经签入了settings.py 文件和html 文件。但一切都很好,但它不起作用。请帮我解决这个问题。文件和css文件的路径一切正常。我还检查了代码,但一切都很好。检查告诉我该文件不存在。但它存在

django django-rest-framework django-views django-templates django-settings
1个回答
0
投票

按照步骤操作

# -------- handle Static Files In Django --------

# Steps:
    # 1 - Create (static) folder in Root Directory of Project
    # 2 - Paste Your Static Files Folder in (static) Folder (js,css,images...etc)
    # 3 - Now Do Setting in (setting.py)
           STATIC_URL = '/static/'

        #    STATICFILES_DIRS = [
        #         os.path.join(BASE_DIR,'static') 
        #     ]
           STATICFILES_DIRS = [BASE_DIR / 'static']
    # 4 - add {% load static %} tag on top of html page
    # 5 - Now use ({% static 'assets/image.jpg' %}) tag in HTML File for calling static files
    # 6 - Done
© www.soinside.com 2019 - 2024. All rights reserved.