Skip to content
Advertisement

How can I take input from a text field in a Django page then update a SQL table with the response?

I am working on a site that will be used to clean up inactive Tableau workbooks. Logging into this site will allow my users to see their old workbooks and decide which ones to keep.

This is going to be accomplished by taking some simple text input from an HTML page, K for keep | D for delete.

The response from the user will then be stored as a Python variable that will go into an if then statement. The if then statement will basically update each row in SQL, adding either K or D to a column called “Marked_for_Deletion”.

From there, a stored procedure will run, check that column, and delete all things marked with a D.

Is this feasible? If so, how would I go about pulling that input and making sure it gets added to the right column/row? If not, can you offer any suggestions on a substitute method I can use?

Thanks!

Edit: Here is the code for my table.

I want to be able to pull the input from the last td tag and store it with the submit button below there.

Advertisement

Answer

I’m kind of late, but I hope it helps you out.

urls.py

models.py

views.py

books.html

P.S. I’m not handling exceptions, messages, etc. You’re just gonna have to figure it out yourself or open a new question.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement