[問題] django使用ckeditor template顯示

看板Python作者 (嘻嘻)時間4年前 (2020/08/01 00:53), 4年前編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
目前在自學django架設網頁,現在遇到一個問題。 在Model配置中,content是使用ckeditor,上傳不只一張圖片, 但我只想顯示特定圖片在template上,不知道該如何設定。 下面是我的程式碼: models.py: class Post(models.Model): content = RichTextUploadingField(config_name='my_config', blank=True, null=True) template: {% extends 'variety_list.html' %} {% block variety %} <h1 class="bg-grey text-secondary text-center">{{ variety }}</h1> <dl> {% for post in variety.post_set.all %} <dt> <a href="{% url 'post-detail' post.pk %}"> {{post.title}} </a> {{ post.type }} {{ post.created_at }} </dt> <dt> <img src="此處該如何使用動態取得圖片"/> </dt> {% endfor %} </dl> {% endblock %} ckeditor編輯器用到的是media不是static setting的media路徑: MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') 請問有方法可以利用django的變數語法{{}}取得ckeditor裡的圖片嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.162.124.114 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1596214392.A.1B9.html ※ 編輯: diho (1.162.124.114 臺灣), 08/01/2020 01:00:25
文章代碼(AID): #1V94nu6v (Python)
文章代碼(AID): #1V94nu6v (Python)