METADATA 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. Metadata-Version: 2.1
  2. Name: djangorestframework
  3. Version: 3.13.1
  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 :: 2.2
  17. Classifier: Framework :: Django :: 3.0
  18. Classifier: Framework :: Django :: 3.1
  19. Classifier: Framework :: Django :: 3.2
  20. Classifier: Framework :: Django :: 4.0
  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. Requires-Dist: django (>=2.2)
  36. Requires-Dist: pytz
  37. # [Django REST framework][docs]
  38. [![build-status-image]][build-status]
  39. [![coverage-status-image]][codecov]
  40. [![pypi-version]][pypi]
  41. **Awesome web-browsable Web APIs.**
  42. Full documentation for the project is available at [https://www.django-rest-framework.org/][docs].
  43. ---
  44. # Funding
  45. REST framework is a *collaboratively funded project*. If you use
  46. REST framework commercially we strongly encourage you to invest in its
  47. continued development by [signing up for a paid plan][funding].
  48. The initial aim is to provide a single full-time position on REST framework.
  49. *Every single sign-up makes a significant impact towards making that possible.*
  50. [![][sentry-img]][sentry-url]
  51. [![][stream-img]][stream-url]
  52. [![][rollbar-img]][rollbar-url]
  53. [![][esg-img]][esg-url]
  54. [![][retool-img]][retool-url]
  55. [![][bitio-img]][bitio-url]
  56. [![][posthog-img]][posthog-url]
  57. [![][cryptapi-img]][cryptapi-url]
  58. Many thanks to all our [wonderful sponsors][sponsors], and in particular to our premium backers, [Sentry][sentry-url], [Stream][stream-url], [Rollbar][rollbar-url], [ESG][esg-url], [Retool][retool-url], [bit.io][bitio-url], [PostHog][posthog-url], and [CryptAPI][cryptapi-url].
  59. ---
  60. # Overview
  61. Django REST framework is a powerful and flexible toolkit for building Web APIs.
  62. Some reasons you might want to use REST framework:
  63. * The [Web browsable API][sandbox] is a huge usability win for your developers.
  64. * [Authentication policies][authentication] including optional packages for [OAuth1a][oauth1-section] and [OAuth2][oauth2-section].
  65. * [Serialization][serializers] that supports both [ORM][modelserializer-section] and [non-ORM][serializer-section] data sources.
  66. * 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].
  67. * [Extensive documentation][docs], and [great community support][group].
  68. There is a live example API for testing purposes, [available here][sandbox].
  69. **Below**: *Screenshot from the browsable API*
  70. ![Screenshot][image]
  71. ----
  72. # Requirements
  73. * Python (3.6, 3.7, 3.8, 3.9, 3.10)
  74. * Django (2.2, 3.0, 3.1, 3.2, 4.0)
  75. We **highly recommend** and only officially support the latest patch release of
  76. each Python and Django series.
  77. # Installation
  78. Install using `pip`...
  79. pip install djangorestframework
  80. Add `'rest_framework'` to your `INSTALLED_APPS` setting.
  81. INSTALLED_APPS = [
  82. ...
  83. 'rest_framework',
  84. ]
  85. # Example
  86. 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.
  87. Startup up a new project like so...
  88. pip install django
  89. pip install djangorestframework
  90. django-admin startproject example .
  91. ./manage.py migrate
  92. ./manage.py createsuperuser
  93. Now edit the `example/urls.py` module in your project:
  94. ```python
  95. from django.urls import path, include
  96. from django.contrib.auth.models import User
  97. from rest_framework import serializers, viewsets, routers
  98. # Serializers define the API representation.
  99. class UserSerializer(serializers.HyperlinkedModelSerializer):
  100. class Meta:
  101. model = User
  102. fields = ['url', 'username', 'email', 'is_staff']
  103. # ViewSets define the view behavior.
  104. class UserViewSet(viewsets.ModelViewSet):
  105. queryset = User.objects.all()
  106. serializer_class = UserSerializer
  107. # Routers provide a way of automatically determining the URL conf.
  108. router = routers.DefaultRouter()
  109. router.register(r'users', UserViewSet)
  110. # Wire up our API using automatic URL routing.
  111. # Additionally, we include login URLs for the browsable API.
  112. urlpatterns = [
  113. path('', include(router.urls)),
  114. path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
  115. ]
  116. ```
  117. We'd also like to configure a couple of settings for our API.
  118. Add the following to your `settings.py` module:
  119. ```python
  120. INSTALLED_APPS = [
  121. ... # Make sure to include the default installed apps here.
  122. 'rest_framework',
  123. ]
  124. REST_FRAMEWORK = {
  125. # Use Django's standard `django.contrib.auth` permissions,
  126. # or allow read-only access for unauthenticated users.
  127. 'DEFAULT_PERMISSION_CLASSES': [
  128. 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly',
  129. ]
  130. }
  131. ```
  132. That's it, we're done!
  133. ./manage.py runserver
  134. 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.
  135. 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:
  136. $ curl -H 'Accept: application/json; indent=4' -u admin:password http://127.0.0.1:8000/users/
  137. [
  138. {
  139. "url": "http://127.0.0.1:8000/users/1/",
  140. "username": "admin",
  141. "email": "admin@example.com",
  142. "is_staff": true,
  143. }
  144. ]
  145. Or to create a new user:
  146. $ 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/
  147. {
  148. "url": "http://127.0.0.1:8000/users/2/",
  149. "username": "new",
  150. "email": "new@example.com",
  151. "is_staff": false,
  152. }
  153. # Documentation & Support
  154. Full documentation for the project is available at [https://www.django-rest-framework.org/][docs].
  155. For questions and support, use the [REST framework discussion group][group], or `#restframework` on libera.chat IRC.
  156. You may also want to [follow the author on Twitter][twitter].
  157. # Security
  158. Please see the [security policy][security-policy].
  159. [build-status-image]: https://github.com/encode/django-rest-framework/actions/workflows/main.yml/badge.svg
  160. [build-status]: https://github.com/encode/django-rest-framework/actions/workflows/main.yml
  161. [coverage-status-image]: https://img.shields.io/codecov/c/github/encode/django-rest-framework/master.svg
  162. [codecov]: https://codecov.io/github/encode/django-rest-framework?branch=master
  163. [pypi-version]: https://img.shields.io/pypi/v/djangorestframework.svg
  164. [pypi]: https://pypi.org/project/djangorestframework/
  165. [twitter]: https://twitter.com/_tomchristie
  166. [group]: https://groups.google.com/forum/?fromgroups#!forum/django-rest-framework
  167. [sandbox]: https://restframework.herokuapp.com/
  168. [funding]: https://fund.django-rest-framework.org/topics/funding/
  169. [sponsors]: https://fund.django-rest-framework.org/topics/funding/#our-sponsors
  170. [sentry-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/sentry-readme.png
  171. [stream-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/stream-readme.png
  172. [rollbar-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/rollbar-readme.png
  173. [esg-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/esg-readme.png
  174. [retool-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/retool-readme.png
  175. [bitio-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/bitio-readme.png
  176. [posthog-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/posthog-readme.png
  177. [cryptapi-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/cryptapi-readme.png
  178. [sentry-url]: https://getsentry.com/welcome/
  179. [stream-url]: https://getstream.io/?utm_source=drf&utm_medium=sponsorship&utm_content=developer
  180. [rollbar-url]: https://rollbar.com/?utm_source=django&utm_medium=sponsorship&utm_campaign=freetrial
  181. [esg-url]: https://software.esg-usa.com/
  182. [retool-url]: https://retool.com/?utm_source=djangorest&utm_medium=sponsorship
  183. [bitio-url]: https://bit.io/jobs?utm_source=DRF&utm_medium=sponsor&utm_campaign=DRF_sponsorship
  184. [posthog-url]: https://posthog.com?utm_source=drf&utm_medium=sponsorship&utm_campaign=open-source-sponsorship
  185. [cryptapi-url]: https://cryptapi.io
  186. [oauth1-section]: https://www.django-rest-framework.org/api-guide/authentication/#django-rest-framework-oauth
  187. [oauth2-section]: https://www.django-rest-framework.org/api-guide/authentication/#django-oauth-toolkit
  188. [serializer-section]: https://www.django-rest-framework.org/api-guide/serializers/#serializers
  189. [modelserializer-section]: https://www.django-rest-framework.org/api-guide/serializers/#modelserializer
  190. [functionview-section]: https://www.django-rest-framework.org/api-guide/views/#function-based-views
  191. [generic-views]: https://www.django-rest-framework.org/api-guide/generic-views/
  192. [viewsets]: https://www.django-rest-framework.org/api-guide/viewsets/
  193. [routers]: https://www.django-rest-framework.org/api-guide/routers/
  194. [serializers]: https://www.django-rest-framework.org/api-guide/serializers/
  195. [authentication]: https://www.django-rest-framework.org/api-guide/authentication/
  196. [image]: https://www.django-rest-framework.org/img/quickstart.png
  197. [docs]: https://www.django-rest-framework.org/
  198. [security-policy]: https://github.com/encode/django-rest-framework/security/policy