Hello Im having some issues trying to pass an id through a modal. Basically I want to pass an id through a modal, via urls.py and to hit a function in the views to delete the user.
This is my modal:
Much appreciated for any help. Fairly new to Django. Really hope someone can come to my rescue :-)
<!-- BEGIN CONFIRM MODAL -->
<div class="modal fade" id="confirmModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">{% trans 'Delete My Account' %}</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
{% trans 'Are you sure you want to delete your account?' %}
</div>
<div class="modal-footer">
<div class="left-side">
<button type="button" class="btn btn-raised btn-default"
data-dismiss="modal">{% trans 'Cancel' %}</button>
</div>
<div class="divider"></div>
<div class="right-side">
class="btn btn-raised btn-danger">{% trans 'Yes, delete me' %}</a>
</div>
</div>
</div>
</div>
</div>
<!-- END CONFIRM MODAL -->
{% block bottomjs %}
<script>
$(function () {
$('#delete-account').on('click', function () {
$('#ms-preload, #status').show();
});
});
</script>
{% endblock %}
URLS>PY
from django.urls import path
from .views import subscriptions, subscribe, unsubscribe,deleteme, get_discounted_value, plan_details, my_subscription, manage_account
urlpatterns = [
path('my-subscription/', my_subscription, name='my_subscription'),
path('manage-account/', manage_account, name='manage_account'),
path('subscriptions/', subscriptions, name='subscriptions'),
path('subscribe/', subscribe, name='subscribe'),
path('unsubscribe/', unsubscribe, name='unsubscribe'),
path('deleteme/<int:id>/', deleteme, name='deleteme'),
path('discounted-value/', get_discounted_value, name='discounted-value'),
path('plan-details/', plan_details, name='plan-details'),
# re_path('discounted-value/(?P<coupon_code>([^/]+))/(?P<original_value>([0-9.]+))/',
# get_discounted_value, name='assessment_question'),
]
VIEWS
@csrf_exempt
def deleteme(request):
request.user.deleteme(request.POST)
return redirect('free_dashboard_index')