Django的CreateView多个表单

时间:2015-09-02 09:22:21

标签: python django

我有两个CreateViews客户和公司。我正在尝试从公司创建页面添加客户端。我以为我只能将表单标记中的action更改为指向客户端URL。当我点击提交时没有任何反应。

urls.py

url(r'^clients/create/$', ClientCreate.as_view(success_url="/app/clients/"), name='clients-create'),

url(r'^company/create/$', CompanyCreate.as_view(), name='company-create'),

views.py

class ClientCreate(CreateView):
    model = Client
    fields = [...]

class CompanyCreate(CreateView):
    model = Company
    fields = [...]

创建-company.html

<form role="form" method="post" action="."> {% csrf_token %}
    <a (Link to popup form)>+</a>
    <form role="form" method="post" action="client/create/">{% csrf_token %}        </form>
</form>

0 个答案:

没有答案