1
0

METADATA 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. Metadata-Version: 2.1
  2. Name: djangorestframework
  3. Version: 3.14.0
  4. Summary: Web APIs for Django, made easy.
  5. Home-page: https://www.django-rest-framework.org/
  6. Author: Tom Christie
  7. Author-email: tom@tomchristie.com
  8. License: BSD
  9. Project-URL: Funding, https://fund.django-rest-framework.org/topics/funding/
  10. Project-URL: Source, https://github.com/encode/django-rest-framework
  11. Project-URL: Changelog, https://www.django-rest-framework.org/community/release-notes/
  12. Platform: UNKNOWN
  13. Classifier: Development Status :: 5 - Production/Stable
  14. Classifier: Environment :: Web Environment
  15. Classifier: Framework :: Django
  16. Classifier: Framework :: Django :: 3.0
  17. Classifier: Framework :: Django :: 3.1
  18. Classifier: Framework :: Django :: 3.2
  19. Classifier: Framework :: Django :: 4.0
  20. Classifier: Framework :: Django :: 4.1
  21. Classifier: Intended Audience :: Developers
  22. Classifier: License :: OSI Approved :: BSD License
  23. Classifier: Operating System :: OS Independent
  24. Classifier: Programming Language :: Python
  25. Classifier: Programming Language :: Python :: 3
  26. Classifier: Programming Language :: Python :: 3.6
  27. Classifier: Programming Language :: Python :: 3.7
  28. Classifier: Programming Language :: Python :: 3.8
  29. Classifier: Programming Language :: Python :: 3.9
  30. Classifier: Programming Language :: Python :: 3.10
  31. Classifier: Programming Language :: Python :: 3 :: Only
  32. Classifier: Topic :: Internet :: WWW/HTTP
  33. Requires-Python: >=3.6
  34. Description-Content-Type: text/markdown
  35. License-File: LICENSE.md
  36. Requires-Dist: django (>=3.0)
  37. Requires-Dist: pytz
  38. # [Django REST framework][docs]
  39. [![build-status-image]][build-status]
  40. [![coverage-status-image]][codecov]
  41. [![pypi-version]][pypi]
  42. **Awesome web-browsable Web APIs.**
  43. Full documentation for the project is available at [https://www.django-rest-framework.org/][docs].
  44. ---
  45. # Funding
  46. REST framework is a *collaboratively funded project*. If you use
  47. REST framework commercially we strongly encourage you to invest in its
  48. continued development by [signing up for a paid plan][funding].
  49. The initial aim is to provide a single full-time position on REST framework.
  50. *Every single sign-up makes a significant impact towards making that possible.*
  51. [![][sentry-img]][sentry-url]
  52. [![][stream-img]][stream-url]
  53. [![][spacinov-img]][spacinov-url]
  54. [![][retool-img]][retool-url]
  55. [![][bitio-img]][bitio-url]
  56. [![][posthog-img]][posthog-url]
  57. [![][cryptapi-img]][cryptapi-url]
  58. [![][fezto-img]][fezto-url]
  59. Many thanks to all our [wonderful sponsors][sponsors], and in particular to our premium backers, [Sentry][sentry-url], [Stream][stream-url], [Spacinov][spacinov-url], [Retool][retool-url], [bit.io][bitio-url], [PostHog][posthog-url], [CryptAPI][cryptapi-url], and [FEZTO][fezto-url].
  60. ---
  61. # Overview
  62. Django REST framework is a powerful and flexible toolkit for building Web APIs.
  63. Some reasons you might want to use REST framework:
  64. * The [Web browsable API][sandbox] is a huge usability win for your developers.
  65. * [Authentication policies][authentication] including optional packages for [OAuth1a][oauth1-section] and [OAuth2][oauth2-section].
  66. * [Serialization][serializers] that supports both [ORM][modelserializer-section] and [non-ORM][serializer-section] data sources.
  67. * Customizable all the way down - just use [regular function-based views][functionview-section] if you don't need the [more][generic-views] [powerful][viewsets] [features][routers].
  68. * [Extensive documentation][docs], and [great community support][group].
  69. There is a live example API for testing purposes, [available here][sandbox].
  70. **Below**: *Screenshot from the browsable API*
  71. ![Screenshot][image]
  72. ----
  73. # Requirements
  74. * Python 3.6+
  75. * Django 4.1, 4.0, 3.2, 3.1, 3.0
  76. We **highly recommend** and only officially support the latest patch release of
  77. each Python and Django series.
  78. # Installation
  79. Install using `pip`...
  80. pip install djangorestframework
  81. Add `'rest_framework'` to your `INSTALLED_APPS` setting.
  82. ```python
  83. INSTALLED_APPS = [
  84. ...
  85. 'rest_framework',
  86. ]
  87. ```
  88. # Example
  89. Let's take a look at a quick example of using REST framework to build a simple model-backed API for accessing users and groups.
  90. Startup up a new project like so...
  91. pip install django
  92. pip install djangorestframework
  93. django-admin startproject example .
  94. ./manage.py migrate
  95. ./manage.py createsuperuser
  96. Now edit the `example/urls.py` module in your project:
  97. ```python
  98. from django.contrib.auth.models import User
  99. from django.urls import include, path
  100. from rest_framework import routers, serializers, viewsets
  101. # Serializers define the API representation.
  102. class UserSerializer(serializers.HyperlinkedModelSerializer):
  103. class Meta:
  104. model = User
  105. fields = ['url', 'username', 'email', 'is_staff']
  106. # ViewSets define the view behavior.
  107. class UserViewSet(viewsets.ModelViewSet):
  108. queryset = User.objects.all()
  109. serializer_class = UserSerializer
  110. # Routers provide a way of automatically determining the URL conf.
  111. router = routers.DefaultRouter()
  112. router.register(r'users', UserViewSet)
  113. # Wire up our API using automatic URL routing.
  114. # Additionally, we include login URLs for the browsable API.
  115. urlpatterns = [
  116. path('', include(router.urls)),
  117. path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
  118. ]
  119. ```
  120. We'd also like to configure a couple of settings for our API.
  121. Add the following to your `settings.py` module:
  122. ```python
  123. INSTALLED_APPS = [
  124. ... # Make sure to include the default installed apps here.
  125. 'rest_framework',
  126. ]
  127. REST_FRAMEWORK = {
  128. # Use Django's standard `django.contrib.auth` permissions,
  129. # or allow read-only access for unauthenticated users.
  130. 'DEFAULT_PERMISSION_CLASSES': [
  131. 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly',
  132. ]
  133. }
  134. ```
  135. That's it, we're done!
  136. ./manage.py runserver
  137. You can now open the API in your browser at `http://127.0.0.1:8000/`, and view your new 'users' API. If you use the `Login` control in the top right corner you'll also be able to add, create and delete users from the system.
  138. You can also interact with the API using command line tools such as [`curl`](https://curl.haxx.se/). For example, to list the users endpoint:
  139. $ curl -H 'Accept: application/json; indent=4' -u admin:password http://127.0.0.1:8000/users/
  140. [
  141. {
  142. "url": "http://127.0.0.1:8000/users/1/",
  143. "username": "admin",
  144. "email": "admin@example.com",
  145. "is_staff": true,
  146. }
  147. ]
  148. Or to create a new user:
  149. $ curl -X POST -d username=new -d email=new@example.com -d is_staff=false -H 'Accept: application/json; indent=4' -u admin:password http://127.0.0.1:8000/users/
  150. {
  151. "url": "http://127.0.0.1:8000/users/2/",
  152. "username": "new",
  153. "email": "new@example.com",
  154. "is_staff": false,
  155. }
  156. # Documentation & Support
  157. Full documentation for the project is available at [https://www.django-rest-framework.org/][docs].
  158. For questions and support, use the [REST framework discussion group][group], or `#restframework` on libera.chat IRC.
  159. You may also want to [follow the author on Twitter][twitter].
  160. # Security
  161. Please see the [security policy][security-policy].
  162. [build-status-image]: https://github.com/encode/django-rest-framework/actions/workflows/main.yml/badge.svg
  163. [build-status]: https://github.com/encode/django-rest-framework/actions/workflows/main.yml
  164. [coverage-status-image]: https://img.shields.io/codecov/c/github/encode/django-rest-framework/master.svg
  165. [codecov]: https://codecov.io/github/encode/django-rest-framework?branch=master
  166. [pypi-version]: https://img.shields.io/pypi/v/djangorestframework.svg
  167. [pypi]: https://pypi.org/project/djangorestframework/
  168. [twitter]: https://twitter.com/starletdreaming
  169. [group]: https://groups.google.com/forum/?fromgroups#!forum/django-rest-framework
  170. [sandbox]: https://restframework.herokuapp.com/
  171. [funding]: https://fund.django-rest-framework.org/topics/funding/
  172. [sponsors]: https://fund.django-rest-framework.org/topics/funding/#our-sponsors
  173. [sentry-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/sentry-readme.png
  174. [stream-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/stream-readme.png
  175. [spacinov-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/spacinov-readme.png
  176. [retool-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/retool-readme.png
  177. [bitio-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/bitio-readme.png
  178. [posthog-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/posthog-readme.png
  179. [cryptapi-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/cryptapi-readme.png
  180. [fezto-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/fezto-readme.png
  181. [sentry-url]: https://getsentry.com/welcome/
  182. [stream-url]: https://getstream.io/?utm_source=DjangoRESTFramework&utm_medium=Webpage_Logo_Ad&utm_content=Developer&utm_campaign=DjangoRESTFramework_Jan2022_HomePage
  183. [spacinov-url]: https://www.spacinov.com/
  184. [retool-url]: https://retool.com/?utm_source=djangorest&utm_medium=sponsorship
  185. [bitio-url]: https://bit.io/jobs?utm_source=DRF&utm_medium=sponsor&utm_campaign=DRF_sponsorship
  186. [posthog-url]: https://posthog.com?utm_source=drf&utm_medium=sponsorship&utm_campaign=open-source-sponsorship
  187. [cryptapi-url]: https://cryptapi.io
  188. [fezto-url]: https://www.fezto.xyz/?utm_source=DjangoRESTFramework
  189. [oauth1-section]: https://www.django-rest-framework.org/api-guide/authentication/#django-rest-framework-oauth
  190. [oauth2-section]: https://www.django-rest-framework.org/api-guide/authentication/#django-oauth-toolkit
  191. [serializer-section]: https://www.django-rest-framework.org/api-guide/serializers/#serializers
  192. [modelserializer-section]: https://www.django-rest-framework.org/api-guide/serializers/#modelserializer
  193. [functionview-section]: https://www.django-rest-framework.org/api-guide/views/#function-based-views
  194. [generic-views]: https://www.django-rest-framework.org/api-guide/generic-views/
  195. [viewsets]: https://www.django-rest-framework.org/api-guide/viewsets/
  196. [routers]: https://www.django-rest-framework.org/api-guide/routers/
  197. [serializers]: https://www.django-rest-framework.org/api-guide/serializers/
  198. [authentication]: https://www.django-rest-framework.org/api-guide/authentication/
  199. [image]: https://www.django-rest-framework.org/img/quickstart.png
  200. [docs]: https://www.django-rest-framework.org/
  201. [security-policy]: https://github.com/encode/django-rest-framework/security/policy