简体   繁体   中英

Is there Django form field or widget that appends Radio and CharField

I'm trying to create a Django form fields that has radio choices and "other" choice that is a text field. It should look like this I tried this but its from 2014 and it's not working. Can you give me an idea how to fix this code or how can I create a custom widget that will do the job. Thank you for your help!

You can use HTML radio button form syntax and insert your Django templates.

    <div>
      <input type="radio" id="test" name="test"
             checked>
      <label for="test">{{ template }}</label>
<input type="radio" name="reason" value="">{{ template }} <input type="text" name="..." />
    </div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM