Quewin Bridger
Quewin Bridger

Reputation: 105

Django Rest Framework and the Frontend

I want to use Django Rest Framework as an API and am looking for a way to "couple" the frontend / HTML/CSS/JS to it. To put it in perspective, I am used to the way Django "usually" does it, by naming HTML templates and 'rendering' them when going to a particular URL.

Now, with DRF, it appears that this functionality has fallen away and everywhere I look it's just "react.js or vue.js" as the answers to consume the API.

What are my options for the front end? Can I not just do it all within the 'usual' Django framework, simply, as it was done before. And why do no resources talk about this?

Thanks, let me know if you require further info.

Upvotes: 10

Views: 6438

Answers (1)

Mike Lazko
Mike Lazko

Reputation: 167

DRF is just additional layer for Django which help to implement API. You can use Django for render html on server side and serve it to browser. You don't need use DRF for it. But if you assume that you frontend app will be interactive, dynamic and complicated then it is not best way to solve it.

More popular approach suggest to separate it on frontend application (react or vue) and backend with REST API for interact with. It allow move all things related with UI on frontend app and only keep state on server.

By the way Django was developed for generate html on server and for site like this https://www.washingtontimes.com/news/ but world changing. Resources talk just about popular things

Upvotes: 4

Related Questions