{"config":{"lang":["en"],"prebuild_index":false,"separator":"[\\s\\-]+"},"docs":[{"location":"","text":".promolia{float:left;width:130px;height:20px;text-align:center;margin:10px30px;padding:150px000;background-position:050%;background-size:130pxauto;background-repeat:no-repeat;font-size:120%;color:black;}.promoli{list-style:none;}DjangoRESTFrameworkDjangoRESTframeworkisapowerfulandflexibletoolkitforbuildingWebAPIs.SomereasonsyoumightwanttouseRESTframework:TheWebbrowsableAPIisahugeusabilitywinforyourdevelopers.AuthenticationpoliciesincludingpackagesforOAuth1aandOAuth2.SerializationthatsupportsbothORMandnon-ORMdatasources.Customizableallthewaydown-justuseregularfunction-basedviewsifyoudon'tneedthemorepowerfulfeatures.Extensivedocumentation,andgreatcommunitysupport.UsedandtrustedbyinternationallyrecognisedcompaniesincludingMozilla,RedHat,Heroku,andEventbrite.FundingRESTframeworkisacollaborativelyfundedproject.IfyouuseRESTframeworkcommerciallywestronglyencourageyoutoinvestinitscontinueddevelopmentbysigningupforapaidplan.Everysinglesign-uphelpsusmakeRESTframeworklong-termfinanciallysustainable.SentryStreamESGRollbarCadreKloudlessLightsOnSoftwareManythankstoallourwonderfulsponsors,andinparticulartoourpremiumbackers,Sentry,Stream,ESG,Rollbar,Cadre,Kloudless,andLightsOnSoftware.RequirementsRESTframeworkrequiresthefollowing:Python(3.5,3.6,3.7)Django(1.11,2.0,2.1,2.2)WehighlyrecommendandonlyofficiallysupportthelatestpatchreleaseofeachPythonandDjangoseries.Thefollowingpackagesareoptional:coreapi(1.32.0+)-Schemagenerationsupport.Markdown(3.0.0+)-MarkdownsupportforthebrowsableAPI.Pygments(2.4.0+)-AddsyntaxhighlightingtoMarkdownprocessing.django-filter(1.0.1+)-Filteringsupport.django-guardian(1.1.1+)-Objectlevelpermissionssupport.InstallationInstallusingpip,includinganyoptionalpackagesyouwant...pipinstalldjangorestframeworkpipinstallmarkdown#MarkdownsupportforthebrowsableAPI.pipinstalldjango-filter#Filteringsupport...orclonetheprojectfromgithub.gitclonehttps://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')) ] Note that the URL path can be whatever you want. Example Let's take a look at a quick example of using REST framework to build a simple model-backed API. We'll create a read-write API for accessing information on the users of our project. Any global settings for a REST framework API are kept in a single configuration dictionary named REST_FRAMEWORK . Start off by adding the following to your settings.py module: REST_FRAMEWORK = { # Use Django's standard `django.contrib.auth` permissions, # or allow read-only access for unauthenticated users. 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' ] } Don't forget to make sure you've also added rest_framework to your INSTALLED_APPS . We're ready to create our API now. Here's our project's root urls.py module: from django.conf.urls import url, include from django.contrib.auth.models import User from rest_framework import routers, serializers, viewsets # Serializers define the API representation. class UserSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = User fields = ['url', 'username', 'email', 'is_staff'] # ViewSets define the view behavior. class UserViewSet(viewsets.ModelViewSet): queryset = User.objects.all() serializer_class = UserSerializer # Routers provide an easy way of automatically determining the URL conf. router = routers.DefaultRouter() router.register(r'