Greetings,

I'm trying to use DRF for an application that will serve both web pages and 
a web API and reduce duplication as much as possible, so I'm trying to 
create both template based views and JSON response based views for the same 
functions using serializers and keep the logic for how the classes are 
saved in the serializers and out of the individual views.

Looking at the DRF documentation I can see how to auto-render a serializer 
using a template pack and with the "render_form" keyword, but I do not see 
any way to manually lay out the template fields individually, ie. {% 
serializer.first_name %} etc.  Since the people who will be doing the 
layout  & style for these forms are not Python developers but HTML/CSS 
developers, it's really not desirable to have the style information in the 
Python code but rather to have HTML elements that can be styled by the UX 
resources in the templates & css files.  Separation of concerns in general 
dictates that it's not the best practice to put the style info into the 
code as well.

Can you please advise on how we can lay out the forms & style manually in 
the template using serializers, analogously to how it is possible using 
Django forms?

If this isn't possible, is it possible to use a serializer to populate a 
Django form and vice-versa so we could use "regular" Django forms in the 
template but still keep all the logic in the common serializer?

Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to