美文网首页
django rest framework 安装依赖

django rest framework 安装依赖

作者: 爱修仙的道友 | 来源:发表于2019-04-24 13:55 被阅读0次

Requirements

REST framework requires the following:

  • Python (2.7, 3.4, 3.5, 3.6, 3.7)
  • Django (1.11, 2.0, 2.1, 2.2)

We highly recommend and only officially support the latest patch release of each Python and Django series.

The following packages are optional:

Installation

Install using pip, including any optional packages you want...

pip install djangorestframework
pip install markdown       # Markdown support for the browsable API.
pip install django-filter  # Filtering support

...or clone the project from github.

git clone https://github.com/encode/django-rest-framework

Add 'rest_framework' to your INSTALLED_APPS setting.

INSTALLED_APPS = (
    ...
    'rest_framework',
)

If you're intending to use the browsable API you'll probably also want to add REST framework's login and logout views. Add the following to your root urls.py file.

urlpatterns = [
    ...
    url(r'^api-auth/', include('rest_framework.urls'))
]

drf 文档配置

from rest_framework.documentation import include_docs_urls

urlpatterns = [
    url(r'^api-auth/', include('rest_framework.urls')),
    # 生产drf自动文档配置
    path('docs/',include_docs_urls(title="商品测试")),
]

Note that the URL path can be whatever you want.

相关文章

网友评论

      本文标题:django rest framework 安装依赖

      本文链接:https://www.haomeiwen.com/subject/yjcggqtx.html