I am new to django, need suggestions/help, we have the following requirement, need to design html template/form using Bootstrap 5 etc… This need to be a single page CRUD application, need to capture master, detail and child data in single page and save it to MySQL database tables, Is this possible in django?
if anybody tried this type of requirement, kindly help me by providing reference articles/documents/blogs to achieve this. We have similar two applications to build, we have done application based on single table only till now, but in the above requirement we have dependent tables this is where I got struck and need help.
Tried single table forms/model/view architecture which are working fine.
Django forms and formsets will allow you to create editable forms for this data.
Then you’re going to want a lot of JavaScript involvement. Any of raw JavaScript, HTMX, jQuery, Vue, React, Angular, etc are going to allow you to build the UI with various degrees of involvement from the server.
(Personally, I’ve become quite enamored with htmx. It has become my tool-of-choice for SPA-style activity.)
It might be helpful if you were more specific with where you’ve gotten stuck. It’ll make it easier to either provide the appropriate resources or to directly assist you.
I have tried with single table i.e. created a model, view and Template and implemented the logic, but I don’t know how my use case can be implemented. I need to use html, bootstrap forms and django, and implement master, detail and child logic in model, view and template.
We need to provide edit, delete buttons in the detail and child forms, user should be allowed to edit record, delete records in the respective forms and same in the master form, when user edits a record we need to provide save functionality. When user delete the parent record the corresponding child records should be deleted automatically. In my case I have two child levels. I got stuck here and looking for help, I am new to Django, my beginner knowledge exhausted and looking for help from Django community me pointing to some references/examples where it is already implemented for similar requirement and understand and learn from django experts and implement it. How and what logic I have to write in model, view and template files to implement my requirement.
How new? Have you worked on any projects beyond the tutorial?
You also need to use JavaScript as I pointed out above.
This type of SPA-style interface cannot be driven or controlled by the server.
Yes, Django can help with creating the HTML for these forms, but ultimately, your UI is going to be implemented using one or more JavaScript libraries.
It may seem overwhelming at first, so break this down into smaller chunks that you can handle one at a time.
It seems to me that a first step could be to create a list view containing your Edit button, but that Edit button brings up a detail view (not a form). Get that working, then convert that detail view into a form with a save button. That will give you all the fundamentals needed to be able to build the rest.
You can also do this with htmx. There is a nice walk-through example of implementation with two tables. It shouldn’t be too hard to extend it to three. Not sure the etiquette for posting links but you can search youtube for “django dynamic forms htmx”
This is my first project, till now I have worked on only single model, view and template. I am using MySQL database as backend.
I found my requirement complicated and am here for getting some help to solve my problem. Could you please let me know how/what I can write in model and html bootstrap template to get edit delete, save buttons and implement the SPA functionality in my application.