简体   繁体   English

django 是一个宁静的 api 吗?

[英]Is django a restful api?

I am confused.我很迷惑。 Some say it is a Restful API and some say it is not.有人说它是一个 Restful API,有人说它不是。

How do we define a RESTful API?我们如何定义 RESTful API? GET,PUT,POST and DELETE commands ? GET、PUT、POST 和 DELETE 命令?

Can I call any web application which is built using django Web framework a Restful API?我可以将使用 django Web 框架构建的任何 Web 应用程序称为 Restful API 吗?

I am confused.我很迷惑。 Some say it is a Restful API and some say it is not.有人说它是一个 Restful API,有人说它不是。

Two different kinds of Django:两种不同的 Django:

  1. Django - a web application framework to rapidly develop web applications Django - 快速开发 Web 应用程序的 Web 应用程序框架

  2. Django REST Framework (DRF) - a powerful framework to create RESTful APIs. Django REST Framework (DRF) - 创建 RESTful API 的强大框架。

Both framework are in Python.两个框架都在 Python 中。

How do we define a RESTful API?我们如何定义 RESTful API? GET,PUT,POST and DELETE commands ? GET、PUT、POST 和 DELETE 命令?

You create an API on your backend application that defines its purpose.您在后端应用程序上创建一个 API 来定义其用途。 If you use DRF for example, and the URL of your API is yourdomain.com/customers/, you can have it to:例如,如果您使用 DRF,并且您的 API 的 URL 是 yourdomain.com/customers/,您可以使用它:

  1. return all the customers information by implementing GET method通过实现 GET 方法返回所有客户信息
  2. create a customer information by implementing POST method ... and so on通过实现 POST 方法创建客户信息......等等

Can I call any web application which is built using django Web framework a Restful API?我可以将使用 django Web 框架构建的任何 Web 应用程序称为 Restful API 吗?

You call it as backend你称之为后端

Django is a web framework to create web backend while REST (REpresentational State Transfer) is an architectural style for developing web services. Django 是一个用于创建 Web 后端的 Web 框架,而 REST(REpresentational State Transfer)是一种用于开发 Web 服务的架构风格。 You can use django to create REST apis.您可以使用 django 来创建 REST api。 You can explore further here:您可以在这里进一步探索:
Django: https://www.djangoproject.com/ Django: https : //www.djangoproject.com/
REST: https://youtu.be/llpr5924N7E休息: https : //youtu.be/llpr5924N7E

What I understood from the web is here:我从网上了解到的是:

  • It should have some commands like PUT, GET, POST and DELETE etc., commands它应该有一些命令,如 PUT、GET、POST 和 DELETE 等,命令
  • The URL of the API should be user/machine understandable API 的 URL 应该是用户/机器可以理解的
  • It should have OAuth secret key and token for each client to access from his它应该有 OAuth 密钥和令牌供每个客户端从他的访问
    application.应用。
  • The URL should be www.api.xyz.com. URL 应为 www.api.xyz.com。 But I am not sure about it to have api in the URL.但我不确定 URL 中是否包含api Can someone confirm it?有人可以确认吗?

And few more constraints to be a RESTful API.以及成为 RESTful API 的更多限制。 Hope all these points are correct.希望所有这些观点都是正确的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM