我正在使用redactor wysiwyg editor來編寫我的內容。該頁面只有wysiwyg編輯器和一個保存按鈕。在django admin中使用外部鏈接創建或更新
HTML:
<div id="editor-wrapper">
<input type="text" id="editor-title" {%if blog %} value="{{blog.title}}" {% else %} placeholder="Your title" {% endif %}>
<textarea id="editor-redactor" name="content">
{% if blog %}
{{ blog.body }}
{% else %}
<p>Enter you body in here...</p>
{% endif %}
</textarea>
<button id="save-btn"><a href="/save-blog/">Save</a> </button>
</div>
而在urls.py我加入的網址進入該頁面。
url(r'^add-update-blog/$', views.add_update_blog),
url(r'^add-update-blog/save/(?P<blog_id>\d+)$', views.add_update_blog),
views.py:現在
def add_update_blog(request):
return render(request, 'editor.html')
def add_update_blog_save(request, blog_id):
blog = Blog.objects.get(id=blog_id)
return render(request, 'editor.html', {
blog: blog
})
,在Django的管理面板有可能是已經寫好內容列表:
- 如果我點擊添加,我想進入編輯頁面。
- 如果我點擊任何已經寫好的內容對象,我想獲取該對象並將其加載到編輯器頁面中。
現在它顯示列表,當我點擊添加或僅在管理面板內顯示的內容時。我如何實現我想要的?你的幫助和指導真的非常敏感。謝謝。