我有以下观点:
class ArticleVideoCreate(CreateView):
model = ArticleVideo
fields = ['article', 'video', 'video_url']
和此网址:
path('', CatalogListView.as_view()),
path('video/<int:article_id>/create', ArticleVideoCreate.as_view(), name='video-create')
我在ListView页面中。我有一个按钮来添加文章视频:
<a href="{% url 'video-create' article.sku %}" class="btn btn-primary btn-sm active" role="button" aria-pressed="true"><ion-icon name="videocam"></ion-icon></a>
在我的articlevideo_form.html中(用于创建文章视频,是模式的):
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
我的问题是,当我单击按钮添加ArticleVideo时,django将我重定向到仅显示模态的video // create。在同一页面上,使用Django来显示CreateView模态的最佳方法是哪种?然后单击创建并在同一页面上完成所有操作?