Why do you use django rest framework?

Asked 2 years ago, Updated 2 years ago, 87 views

I'm trying to make an app and web together while playing django.

I'm going to use the restful method to send and receive data in the app.

But there's a thing called django restframework, but I don't know why I use it.

Shouldn't we just use the class base view in django and return it to json?

Another thing I'm curious about is that if you built an API server with restframework,

You can't even use HttpResponse or Redirect like django.shortcut.

If this is the case, do I have to code only at the front end through the server?

Or do you work on the template part and the api (json) part separately according to the header?

restful restframework django

2022-09-21 20:26

1 Answers

As I said, it's actually possible to use anything like fbv or cbv if you use something like Json Response.

DRF (Django Rest Framework) provides functions such as authentication and permission, making it easier to configure restapi.

Originally, you have to configure the api and test it daily with curl or a dedicated test tool, but if you use drf, you can request and test it directly from the browser

There are people who purposely make and use the drf because it looks like a beggar.

I don't know if you're configuring the app on a page that runs on django directly, but if you're thinking of using it in an app, you have to turn off the csrf_token function

I will only use it on my homepage and it is simple => FBV, solder iron

I'm going to use the app or other people => DRF Recommended


2022-09-21 20:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.