@@ -105,7 +108,7 @@
${item.fields.n
refreshItems()
function addItem() {
- fetch("{% url 'main:add_item_ajax' %}", {
+ fetch("{% url 'main:create_ajax' %}", {
method: "POST",
body: new FormData(document.querySelector('#form'))
}).then(refreshItems)
diff --git a/main/urls.py b/main/urls.py
index 627438e..7d545b8 100644
--- a/main/urls.py
+++ b/main/urls.py
@@ -1,5 +1,5 @@
from django.urls import path
-from main.views import show_main, create_item, show_xml, show_json, show_json_by_id, show_xml_by_id, show_html, show_html_by_id, register, login_user, logout_user, add_amount, remove_item,delete_amount, add_item_ajax, get_item_json, delete_item_ajax
+from main.views import show_main, create_item, show_xml, show_json, show_json_by_id, show_xml_by_id, show_html, show_html_by_id, register, login_user, logout_user, add_amount, remove_item,delete_amount, create_ajax, get_item_json, delete_item_ajax
app_name = 'main'
@@ -14,7 +14,7 @@
path('json/', show_json, name='show_json'),
path('register/', register, name='register'),
path('get-item/', get_item_json, name='get_item_json'),
- path('create-item-ajax/', add_item_ajax, name='add_item_ajax'),
+ path('create-ajax/', create_ajax, name='create_ajax'),
path('delete-item-ajax//', delete_item_ajax, name='delete_item_ajax'),
path('login/', login_user, name='login'),
path('logout/', logout_user, name='logout'),
diff --git a/main/views.py b/main/views.py
index 13c5e78..d13fecc 100644
--- a/main/views.py
+++ b/main/views.py
@@ -74,7 +74,7 @@ def get_item_json(request):
return HttpResponse(serializers.serialize('json', product_item))
@csrf_exempt
-def add_item_ajax(request):
+def create_ajax(request):
if request.method == 'POST':
name = request.POST.get("name")
price = request.POST.get("price")