Django STATIC_URL is empty, images doesn't show

后端 未结 2 1566
清酒与你
清酒与你 2021-01-28 21:13

I know that there is plenty of questions like that, I read them all and tried everything, however nothing solved my problem.

I\'m writing something like blog in Django

相关标签:
2条回答
  • 2021-01-28 21:28

    It appears that you need to refer to MEDIA instead of STATIC in this case.

    Take a look at your MEDIA_ROOT and MEDIA_URL in settings to ensure they're pointed to the right place.

    Then, in your template, you can get the URL for the object via the attribute:

    <img src="{{ comment.author.picture.url }}" width="70px" height="70px">

    More on MEDIA in the docs: https://docs.djangoproject.com/en/1.9/ref/settings/#std:setting-MEDIA_ROOT

    0 讨论(0)
  • 2021-01-28 21:49

    Try changing MEDIA_URL to '/static/users/'

    0 讨论(0)
提交回复
热议问题