RelatedFieldWidgetCanAdd

This commit is contained in:
Anastasia
2015-08-04 15:20:54 +05:00
parent a1acf76886
commit aaab305aba
9 changed files with 100 additions and 24 deletions

View File

@@ -8,6 +8,22 @@
{% inplace_static %}
<link rel="stylesheet" href="{{ STATIC_URL }}django_tables2/themes/paleblue/css/screen.css" />
<link rel="stylesheet" href="{{ STATIC_URL }}admin/css/base.css" />
<script type="text/javascript" src="/static/admin/js/admin/RelatedObjectLookups.js">
function showAddAnotherPopup(triggeringLink) {
var name = triggeringLink.id.replace(/^add_/, '');
name = id_to_windowname(name);
href = triggeringLink.href
if (href.indexOf('?') == -1) {
href += '?_popup=1';
} else {
href += '&_popup=1';
}
var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
win.focus();
return false;
}
</script>
<style>
#menu {
margin: 0; /* Обнуляем значение отступов */

View File

@@ -3,8 +3,8 @@
{% load render_table from django_tables2 %}
{% block page %}
<div class="inline" style="width:38%;"><div><h3>{{ table1.verbose_name }}</h3></div>{% render_table table1 %}</div>
<div class="inline" style="width:20%;"><div><h3>{{ table2.verbose_name }}</h3></div>{% render_table table2 %}</div>
<div class="inline"><div><h3>{{ table1.verbose_name }}</h3></div>{% render_table table1 %}</div>
<div class="inline"><div><h3>{{ table2.verbose_name }}</h3></div>{% render_table table2 %}</div>
{% if order_form %}
<form action="{% url 'add-order' %}" method="POST" >
{% csrf_token %}

View File

@@ -2,6 +2,7 @@
{% load django_tables2 %}
{% load i18n %}
{% block table.tbody %}
<tbody>
{% for row in table.page.object_list|default:table.rows %} {# support pagination #}
{% block table.tbody.row %}
@@ -18,21 +19,19 @@
{% endblock table.tbody.empty_text %}
{% endif %}
{% endfor %}
{% if model_form %}
<form action="{% url 'add-order' %}" method="POST" >
{% if add_form %}
{% if params %}
<form action="{% url form_action params %}" method="POST" >
{% else %}
<form action="{% url form_action %}" method="POST" >
{% endif %}
{% csrf_token %}
<tr>
<td>{{model_form.product}}</td>
<td>{{model_form.price}}</td>
<td>{{model_form.paid}}</td>
<td>{{model_form.address}}</td>
<td></td>
<td>{{model_form.deadline}}</td>
<td>{{model_form.delivery}}</td>
<td>{{model_form.lifting}}</td>
{% for field in add_form %}
<td>{{field}}</td>
{% endfor %}
</tr>
<tr>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<td><input type="submit" text="Добавить заказ"></td>
</tr>
</form>