Bugfix: ajax not working while using SCRIPT_NAME
This commit is contained in:
parent
3c22af1933
commit
75fe83a41f
3 changed files with 21 additions and 6 deletions
|
@ -1,4 +1,5 @@
|
|||
"""backend URL Configuration
|
||||
"""
|
||||
backend URL Configuration
|
||||
"""
|
||||
|
||||
from rest_framework import routers
|
||||
|
@ -7,8 +8,16 @@ from .views import BudgetGroupViewSet, BudgetLineViewSet
|
|||
|
||||
router = routers.DefaultRouter()
|
||||
|
||||
router.register(r"budgetgroup", BudgetGroupViewSet)
|
||||
router.register(r"budgetline", BudgetLineViewSet)
|
||||
router.register(
|
||||
r"budgetgroup",
|
||||
BudgetGroupViewSet,
|
||||
basename="budgetgroup",
|
||||
)
|
||||
router.register(
|
||||
r"budgetline",
|
||||
BudgetLineViewSet,
|
||||
basename="budgetline",
|
||||
)
|
||||
|
||||
app_name = "budget-backend"
|
||||
urlpatterns = router.urls
|
||||
|
|
|
@ -17,7 +17,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
.split('; ')
|
||||
.find((row) => row.startsWith('csrftoken='))
|
||||
?.split('=')[1];
|
||||
const url = `/api/budget/budgetline/${target}/`;
|
||||
const url = el.dataset.lineurl;
|
||||
tableLine.classList.add("tr-disabled");
|
||||
await fetch(url, {
|
||||
method: 'DELETE',
|
||||
|
@ -27,7 +27,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
}).then((resp) => {
|
||||
if(resp.ok) {
|
||||
tableLine.remove();
|
||||
const url = `/api/budget/budgetgroup/${group}`;
|
||||
const url = el.dataset.groupurl;
|
||||
budgetAmount.innerHTML = "---";
|
||||
return fetch(url);
|
||||
} else {
|
||||
|
|
|
@ -83,7 +83,13 @@
|
|||
<span class="icon"><i class="fa-solid fa-pen-to-square"></i></span>
|
||||
</a>
|
||||
{% if perms.budget.delete_budgetline %}
|
||||
<button data-lineid="{{ line.id }}" data-groupid="{{ budgetGroup.id }}" class="delete-budgetline button">
|
||||
<button
|
||||
data-lineid="{{ line.id }}"
|
||||
data-groupid="{{ budgetGroup.id }}"
|
||||
data-lineurl="{% url "budget-backend:budgetline-detail" line.id %}"
|
||||
data-groupurl="{% url "budget-backend:budgetgroup-detail" budgetGroup.id %}"
|
||||
class="delete-budgetline button"
|
||||
>
|
||||
<span class="icon"><i class="fa-solid fa-trash"></i></span>
|
||||
</button>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in a new issue