1

我不知道为什么不加载模板,但每次我点击一个 url 页面自动重新加载而不加载模板,这是我的代码:

网址.py

url(r'^pedidos/add',forms.PedidoCreateView.as_view(), name="pedido_add")

表格.py

class PedidoCreateView(CreateView):
   template_name = 'ventas/form_pedido.html'
   model = Pedido
   form_class = PedidoModelForm
   success_url = 'ventas/pedidos.html'


   def form_valid(self, form):
       form.save(commit=True)
       return super(PedidoCreateView, self).form_valid(form)

form_pedido.html

{% extends '_layouts/base.html' %}
{% load url from future %}


{% block breadcrumb%}
    <li>
        <a href="{% url 'ventas:pedidos_list' %}">Pedidos</a>
        <span class="divider">
            <i class="icon-angle-right"></i>
        </span>
    </li>
    <li class="active">Nuevo Pedido</li>
{% endblock %}

{% block page_content %}
    <form class ="form" id="form" method="POST" action="{{ request.path }}">
    <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h3>Editar Empleado</h3>
    </div>

        <div class="modal-body">
            {% csrf_token %}
             {{ form.non_field_errors }}
               {{ form_errors }}
            {{form.as_p}}
        </div>
        <div class="modal-footer">
            <a href="#" data-dismiss="modal" class="cerrar btn">Cerrar</a>
            <input type="submit" class="guardar btn btn-primary" value="Guardar">
     </div>
</form>
{% endblock %}


{% block scripts %}
{% endblock %}

关联

<a href="{% url 'ventas:pedido_add' %}" class="btn btn-app btn-success">

肯定有一些我现在看不到的错误,我用其他类似的观点证明并且我没有任何问题,可能是什么?

4

0 回答 0