0

I have a text field

<input type="text" value="This is a test." name="mytextbox" size="10"/>

and separated from that a button

<button type = "button" class="btn btn-primary">
    <font size="1">Run</font>
</button>

that should update a list and update the value of the text field itself.

Sometimes forms are used in this context, but I would have to wrap the forms tag around the whole template when the input and button are separated on the screen.

Since I am relatively new to Django, I would like to know the best strategy to solve the problem.

  • a) Reload the complete page template with changed arguments/context

  • b) Create a html template of the specific part that extends the main template and only try to render/update this one.

  • c) Do something smarter.

There are some answers in a (much older) post from 8 years ago but I am interested in the state-of-the-art solution.

Uwe.Schneider
  • 1,112
  • 1
  • 15
  • 28
  • The accepted answer on the linked post is probably the best approach. You'd need javascript to update the field value, so that makes most sense. – markwalker_ Apr 16 '22 at 22:03
  • Is it not possible to receive the data from the field value and render the text-field again with a new default value? – Uwe.Schneider Apr 16 '22 at 22:09
  • Yes, if you wanted to reload the page you could just pass the value to a view by making the field part of a form. – markwalker_ Apr 16 '22 at 22:36

0 Answers0