[Answered ]-Django Rest Framework render_form & required fields

2👍

I can see 2 ways:

you can define your own template pack, look at the existing ones in the sources (e.g. ‘rest_framework/horizontal/input.html’) – you can check if field is required and according to this flag, set some css. you do not need something extra, especially “input-readonly.html” – just make your own copy of input.html, add few if-s and it will work.

or you can call OPTIONS on the API endpoint to get all the necessary information about fields, not only required, but readonly and allowed values for some selects – this is if you can update your forms from javascript

👤Jerzyk

Leave a comment