Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are Django forms ever used in Django Rest Framework?

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?

like image 965
John Tacos Avatar asked Jun 14 '19 02:06

John Tacos


People also ask

Can I use Django and Django REST Framework together?

Django Rest Framework makes it easy to use your Django Server as an REST API. REST stands for "representational state transfer" and API stands for application programming interface. Note that with DRF you easily have list and create views as well as authentication.

Is Django different from Django REST Framework?

Django is the web development framework in python whereas the Django Rest Framework is the library used in Django to build Rest APIs. Django Rest Framework is especially designed to make the CRUD operations easier to design in Django. Django Rest Framework makes it easy to use your Django Server as an REST API.

Is Django GOOD FOR REST API?

Django REST framework (DRF) is a powerful and flexible toolkit for building Web APIs. Its main benefit is that it makes serialization much easier. Django REST framework is based on Django's class-based views, so it's an excellent option if you're familiar with Django.

Which is better Django or Django REST Framework?

Django is a framework that is used for the backend part while the Django REST is used to render the database file in JSON or XML so that frontend can understand although Django self can do this thing but Django REST has many more features also. So it is good to use Django REST.


1 Answers

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.

like image 161
anjaneyulubatta505 Avatar answered Sep 28 '22 02:09

anjaneyulubatta505