mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-06-13 10:03:20 +03:00
AJAX forms in admin interface
This commit is contained in:
parent
b8ebe29844
commit
eec1156f63
File diff suppressed because one or more lines are too long
|
@ -104,9 +104,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if delete_form %}
|
{% if delete_form %}
|
||||||
<form class="button-form" action="{{ request.get_full_path }}" method="POST">
|
<form class="button-form" action="{{ request.get_full_path }}" data-method="DELETE">
|
||||||
{% csrf_token %}
|
|
||||||
<input type="hidden" name="{{ api_settings.FORM_METHOD_OVERRIDE }}" value="DELETE" />
|
|
||||||
<button class="btn btn-danger">
|
<button class="btn btn-danger">
|
||||||
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Delete
|
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Delete
|
||||||
</button>
|
</button>
|
||||||
|
@ -180,7 +178,7 @@
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||||
<h4 class="modal-title" id="myModalLabel">Edit</h4>
|
<h4 class="modal-title" id="myModalLabel">Edit</h4>
|
||||||
</div>
|
</div>
|
||||||
<form action="{{ request.get_full_path }}" method="POST" enctype="multipart/form-data" class="form-horizontal" novalidate>
|
<form action="{{ request.get_full_path }}" data-method="PUT" enctype="multipart/form-data" class="form-horizontal" novalidate>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
{{ put_form }}
|
{{ put_form }}
|
||||||
|
@ -188,7 +186,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||||
<button name="{{ api_settings.FORM_METHOD_OVERRIDE }}" value="PUT" type="submit" class="btn btn-primary">Save</button>
|
<button type="submit" class="btn btn-primary">Save</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -204,7 +202,7 @@
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||||
<h4 class="modal-title" id="myModalLabel">{{ error_title }}</h4>
|
<h4 class="modal-title" id="myModalLabel">{{ error_title }}</h4>
|
||||||
</div>
|
</div>
|
||||||
<form action="{{ request.get_full_path }}" method="POST" enctype="multipart/form-data" class="form-horizontal" novalidate>
|
<form action="{{ request.get_full_path }}" data-method="{{ request.method }}" enctype="multipart/form-data" class="form-horizontal" novalidate>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
{{ error_form }}
|
{{ error_form }}
|
||||||
|
@ -212,7 +210,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||||
<button name="{{ api_settings.FORM_METHOD_OVERRIDE }}" value="{{ request.method }}" type="submit" class="btn btn-primary">Save</button>
|
<button type="submit" class="btn btn-primary">Save</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -221,10 +219,17 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% block script %}
|
{% block script %}
|
||||||
<script src="{% static "rest_framework/js/jquery-1.8.1-min.js" %}"></script>
|
<script src="{% static "rest_framework/js/jquery-1.11.3-min.js" %}"></script>
|
||||||
|
<script src="{% static "rest_framework/js/ajax-form.js" %}"></script>
|
||||||
|
<script src="{% static "rest_framework/js/csrf.js" %}"></script>
|
||||||
<script src="{% static "rest_framework/js/bootstrap.min.js" %}"></script>
|
<script src="{% static "rest_framework/js/bootstrap.min.js" %}"></script>
|
||||||
<script src="{% static "rest_framework/js/prettify-min.js" %}"></script>
|
<script src="{% static "rest_framework/js/prettify-min.js" %}"></script>
|
||||||
<script src="{% static "rest_framework/js/default.js" %}"></script>
|
<script src="{% static "rest_framework/js/default.js" %}"></script>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('form').ajaxForm();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</body>
|
</body>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user