How can I make a Django field that renders itself as a pair of input fields?
Reasoning: I am trying to write a new custom field. I will use it for a captcha-like service. The service works by requesting a question - then receiving one and a token. The validation happens by sending the answer along with the token. I want to write a form field that encapsulates this logic. The elements should render (IMO) like
<input type="hidden" name="_token" value="1234567890" />
<input type="text" name="answer" />
And on submit I need the value of _token
and answer
to validate the answer.
I think you're looking for the MultiWidget, you can simply give it 2 regular widgets and it will render the combination.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With