Python "24th Lesson" Django Rest Framework

Source: Internet
Author: User
Tags install django pip install django

The content of this section
    1. Django Rest Framework Installation

    2. Django Rest framwwork Environment configuration

    3. Simple example Description
    4. Using the rest framework in Django

1.1 Installing the Django rest Framework

Create a new environment

Virtualenv Envsource Env/bin/activate

Installationdjangorestframework 模块

Pip Install djangopip install djangorestframeworkpip install Markdown # markdown support for the browsable api.pip install Django-filter # Filtering Support
2 Django REST Framework Environment Configuration 1. Configuring the Settings file

Add ' rest_framework ' to the Installed_apps of the project configuration file settings

Add content to the last line of settings: Allow unauthenticated user read-only permissions

Rest_framework = {    # use Django's standard ' Django.contrib.auth ' permissions,    # or allow read-only access for Unau thenticated users.    ' Default_permission_classes ': [        ' rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly '    ]}
3 Simple examples

Let's look at the directory structure of my Django project.

The first step is to add the rest framework's pointing information under the settings of the CRM

Urlpatterns = [    url (R ' ^api/', include (' Rest.urls ')),]

Asdfasdf

Python "24th Lesson" Django Rest Framework

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.