我用可在edit.html文件上呈现的表单制作了views.py,但我想将该表单弹出到另一个页面上。 我已经试过了:-----
我的views.py
def editButton(request,event_id=37000):
time = timezone.now()
status =False
if request.method == 'POST':
form = EditForm(request.POST)
if form.is_valid():
name = request.POST.get('website_name')
link = request.POST.get('link')
prom = request.POST.get('promotion_status')
part = request.POST.get('partner_status')
.......
return redirect('admin-panel/event_list')
else:
form = EditForm()
return render(request , 'admin_panel/edit.html',{'form':form})
my details.html实际上要在哪里弹出表单:
<html>
<a href="{% url 'admin-panel/edit' event_id=37000 %}" data-toggle="modal" href="#editModal">Edit</a>
{% include "admin_panel/edit.html" %}
</html>
我的edit.html
<div class="modal hide" id="contactModal">
<form class="well" method="post">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3>Editing Contact</h3>
</div>
<div class="modal-body">
{% csrf_token %}
{{form.as_p}}
</div>
<div class="modal-footer">
<input class="btn btn-primary" type="submit" value="Save" />
<input name="cancel" class="btn" type="submit" value="Cancel"/>
</div>
</form>
</div>
我的url.py
urlpatterns =[
path('',views.admin_home,name = 'home'),
path('edit/<int:event_id>',views.editButton,name='edit'),
回溯:
File "C:\Users\J A X\Anaconda3\envs\madeenv\lib\site-packages\django \core\handlers\exception.py" in inner
34. response = get_response(request)
File "C:\Users\J A X\Anaconda3\envs\madeenv\lib\site-packages\django\core\handlers\base.py" in _get_response
156. response = self.process_exception_by_middleware(e, request)
File "C:\Users\J A X\Anaconda3\envs\madeenv\lib\site-packages\django\core\handlers\base.py" in _get_response
154. response = response.render()
File "C:\Users\J A X\Anaconda3\envs\madeenv\lib\site-packages\django\template\response.py" in render
106. self.content = self.rendered_content
File "C:\Users\J A X\Anaconda3\envs\madeenv\lib\site-packages\rest_framework\response.py" in rendered_content
72. ret = renderer.render(self.data, accepted_media_type, context)
File "C:\Users\J A X\Anaconda3\envs\madeenv\lib\site-packages\rest_framework\renderers.py" in render
178. return template.render(context, request=request)
File "C:\Users\J A X\Anaconda3\envs\madeenv\lib\site-packages\django\template\backends\django.py" in render
61. return self.template.render(context)
File "C:\Users\J A X\Anaconda3\envs\madeenv\lib\site-packages\django\template\base.py" in render
171. return self._render(context)
File "C:\Users\J A X\Anaconda3\envs\madeenv\lib\site-packages\django\test\utils.py" in instrumented_test_render
96. return self.nodelist.render(context)
File "C:\Users\J A X\Anaconda3\envs\madeenv\lib\site-packages\django\template\base.py" in render
937. bit = node.render_annotated(context)
File "C:\Users\J A X\Anaconda3\envs\madeenv\lib\site-packages\django\template\base.py" in render_annotated
904. return self.render(context)
File "C:\Users\J A X\Anaconda3\envs\madeenv\lib\site-packages\django\template\loader_tags.py" in render
150. return compiled_parent._render(context)
File "C:\Users\J A X\Anaconda3\envs\madeenv\lib\site-packages\django\test\utils.py" in instrumented_test_render
96. return self.nodelist.render(context)
File "C:\Users\J A X\Anaconda3\envs\madeenv\lib\site-packages\django\template\base.py" in render
937. bit = node.render_annotated(context)
File "C:\Users\J A X\Anaconda3\envs\madeenv\lib\site-packages\django\template\base.py" in render_annotated
904. return self.render(context)
File "C:\Users\J A X\Anaconda3\envs\madeenv\lib\site-packages\django\template\loader_tags.py" in render
62. result = block.nodelist.render(context)
渲染中的文件“ C:\ Users \ J X \ Anaconda3 \ envs \ madeenv \ lib \ site-packages \ django \ template \ base.py”
937. bit = node.render_annotated(context)
render_annotated中的文件“ C:\ Users \ J X \ Anaconda3 \ envs \ madeenv \ lib \ site-packages \ django \ template \ base.py”
904. return self.render(context)
渲染中的文件“ C:\ Users \ J A X \ Anaconda3 \ envs \ madeenv \ lib \ site-packages \ django \ template \ defaulttags.py”
442. url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
反向下载文件“ C:\ Users \ J X \ Anaconda3 \ envs \ madeenv \ lib \ site-packages \ django \ urls \ base.py”
90. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
_reverse_with_prefix中的文件“ C:\ Users \ J X \ Anaconda3 \ envs \ madeenv \ lib \ site-packages \ django \ urls \ resolvers.py”
622. raise NoReverseMatch(msg)
异常类型:/ admin-site / event-details / 36619处的NoReverseMatch 异常值:找不到与“管理面板/编辑”相反的值。 “ admin-panel / edit”不是有效的视图功能或模式名称。