1👍
So, to clarify:
You have a page to manage a list of items (create, edit and remove).
You want a modal to be able to show the forms for creating, editing these objects.
You already have the pages set up for these two actions you wish to perform that you have setup as Class Based Views (CustomerCreateView, CustomerUpdateView).
What you need to do is trigger an AJAX call to these views via ‘GET’ request when the modal is opened. Then, return the template of these views as HTML and populate your modal with this content.
E.g. for the CreateView:
$.ajax({
url: {% url 'create' %},
dataType: "html",
method: "GET",
success: function(data){
$("#createModal").html(data);
}
});
Similarly, you can do this for UpdateView but ofcourse you must pass the id of the object as a parameter in the Ajax.
Hope this helps!
Source:stackexchange.com