6
votes

The DRF tutorial includes the following line about DRF serializers vs Django forms:

   The first thing we need to get started on our Web API is to provide a 
   way of serializing and deserializing the snippet instances into 
   representations such as json. We can do this by declaring serializers 
   that work very similar to Django's forms. 

But from what I can see, it says nothing else about the relationship between forms and serializers.

Since DRF doesn't need the Forms' ability to render a model in a template, is it fair to assume that Forms have no purpose in DRF, and that serializers can handle all of the validation traditionally completed with forms?

If so, when I'm building an API, can I forget about templates and forms entirely?

1
You can definitively forget about forms and templates when you are building a REST API. The internal serializer api is very similar to the form internal api is what your quote says.Jelmer

1 Answers

5
votes

Django REST Framework is used for creating REST API's which send XML or JSON.

Django Forms is used for creating HTML forms based on a given model.

As the role of an API generally doesn't involve sending HTML, Django forms would not be used.