File: PKG-INFO

package info (click to toggle)
drf-generators 0.5.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 140 kB
  • sloc: python: 361; makefile: 3
file content (304 lines) | stat: -rw-r--r-- 10,570 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
Metadata-Version: 1.1
Name: drf-generators
Version: 0.5.0
Summary: Generate DRF Serializers, Views, and urls for your API application.
Home-page: https://github.com/brobin/drf-generators
Author: Tobin Brown
Author-email: tobin@brobin.me
License: MIT
Download-URL: https://github.com/brobin/drf-generators/archive/0.5.0.zip
Description: ==============
        DRF Generators
        ==============
        
        Writing APIs can be boring and repetitive work. Don't write another CRUDdy view in `Django Rest Framework <http://github.com/tomchristie/django-rest-framework>`_. With DRF Generators, one simple command will generate all of your Views, Serializers, and even Urls for your Django Rest Framework application!
        
        For a full step-by-step tutorial, check out my `blog post <http://brobin.me/blog/2015/4/13/how-to-quickly-write-an-api-in-django>`_!
        
        This is **not** intended to give you a production quality API. It was intended to jumpstart your development and save you from writing the same code over and over for each model.
        
        ---------------
        
        |python| |pypi| |license| |travis| |django| |drf|
        
        ---------------
        
        * `Installation`_
        * `Usage`_
        * `Serializers`_
        * `Views`_
        * `Urls`_
        * `Tests`_
        * `License`_
        
        ---------------
        
        ============
        Installation
        ============
        
        Install with pip:
        
        .. code-block:: bash
        
            $ pip install drf-generators
        
        or Clone the repo and install manually:
        
        .. code-block:: bash
        
            $ git clone https://github.com/brobin/drf-generators.git
            $ cd drf-generators
            $ python setup.py install
        
        To use DRF Generators, add it your INSTALLED_APPS.
        
        .. code-block:: python
        
            INSTALLED_APPS = (
                ...
                'rest_framework',
                'drf_generators',
                ...
            )
        
        *Note*: In order to use the APIView classes, you must have the rest framework DEFAULT_PAGINATION_CLASS and PAGE_SIZE set.
        
        .. code-block:: python
        
            REST_FRAMEWORK = {
                'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
                'PAGE_SIZE': 15
            }
        
        -----------------
        
        =====
        Usage
        =====
        
        To use the generators, run the following command, where ``app`` is the application to generate an API for.
        
        .. code-block:: bash
        
           $ python manage.py generate {app} {options}
        
        ========================== ===================================================
        Option                     Action
        ========================== ===================================================
        ``--serializers``          Generate only Serializers for your app.
        ``--views``                Generate only Views for your app.
        ``--urls``                 Generate only urls for your app.
        ``--force``                Overwrite existing files without the warning prompt.
        ``-f``, ``--format``       Format to use when generating views and urls. Valid options: ``viewset``, ``apiview``, ``function``, ``modelviewset``. Default: ``viewset``.
        ``-d``, ``--depth``        Serialization depth for related models. Default: 0
        ========================== ===================================================
        
        **Example:** Generate everything for the app ``api`` with function style views, overwriting existing files, with a serialization depth of 2.
        
        .. code-block:: bash
        
            $ python manage.py generate api --format function --force -- depth=2
        
        -------------------
        
        ===========
        Serializers
        ===========
        
        Drf Generators will create ``serializers.py`` for your application. It currently uses rest framework's ``ModelSerializer`` for serialization of the models defined in ``models.py``.
        
        .. code-block:: python
        
            class ModelSerializer(serializers.ModelSerializer):
        
                class Meta:
                    model = User
        
        ------------------
        
        =====
        Views
        =====
        
        DRF Generators will create ``views.py`` for your application. It can generate ``ViewSet``, ``APIView`` and function based views. Set the ``--format`` option when running the generator to pick the preferred style
        
        -------
        ViewSet
        -------
        
        ``python manage.py generate api  --format viewset``
        
        .. code-block:: python
        
            class ModelViewSet(ViewSet):
        
                def list(self, request):
                    ...
                def create(self, request):
                    ...
                def retrieve(self, request, pk=None):
                    ...
                def update(self, request, pk=None):
                    ...
                def destroy(self, request, pk=None):
                    ...
        
        -------
        APIView
        -------
        
        ``python manage.py generate api --format apiview``
        
        .. code-block:: python
        
            class ModelAPIView(APIView):
        
                def get(self, request, id, format=None):
                    ...
                def put(self, request, id, format=None):
                    ...
                def delete(self, request, id, format=None):
                    ...
        
            class ModelAPIListView(APIView):
        
                def get(self, request, format=None):
                    ...
                def post(self, request, format=None):
                    ...
        
        --------
        Function
        --------
        
        ``python manage.py generate api --format function``
        
        .. code-block:: python
        
            @api_view(['GET', 'POST'])
            def model_list(request):
                if request.method == 'GET':
                    ...
                elif request.method == 'POST':
                    ...
        
            @api_view(['GET', 'PUT', 'DELETE'])
            def model_detail(request, pk):
                if request.method == 'GET':
                    ...
                elif request.method == 'PUT':
                    ...
                elif request.method == 'DELETE':
                    ...
        
        -------------
        ModelViewSet
        -------------
        
        ``python manage.py generate api --format modelviewset``
        
        .. code-block:: python
        
            class MyModelViewSet(ModelViewSet):
                queryset = MyModel.objects.all()
                serializer_class = MyModelSerializer
        
        -----------------
        
        ====
        Urls
        ====
        
        Finally, DRF Generator will create you a default ``urls.py`` to match the View format you are using.
        
        ----------------------------
        ViewSet & ModeViewSet Routes
        ----------------------------
        
        .. code-block:: python
        
            router = SimpleRouter()
        
            router.register(r'model', views.ModelViewSet, 'Model')
        
            urlpatterns = router.urls
        
        ------------
        APIView urls
        ------------
        
        .. code-block:: python
        
            url(r'^model/([0-9]+)$', views.ModelAPIView.as_view()),
            url(r'^model', views.ModelAPIListView.as_view()),
        
        -------------
        Function urls
        -------------
        
        .. code-block:: python
        
            urlpatterns = [
        
                url(r'^model/(?P<pk>[0-9]+)$', views.model_detail),
                url(r'^model/$', views.model_list),
        
            ]
        
            urlpatterns = format_suffix_patterns(urlpatterns)
        
        
        =====
        Tests
        =====
        
        A full application built with drf-generators can be found in the `tests directory <http://github.com/brobin/drf-generators/tree/master/tests>`_. Instructions on running the tests can be found in the test project's README.
        
        
        =======
        License
        =======
        
        MIT License. See `LICENSE <https://github.com/brobin/drf-generators/blob/master/LICENSE>`_.
        
        
        .. |python| image:: https://img.shields.io/pypi/v/drf-generators.svg?style=flat-square
            :target: https://pypi.python.org/pypi/drf-generators/
            :alt: Supported Python versions
        
        .. |pypi| image:: https://img.shields.io/pypi/pyversions/drf-generators.svg?style=flat-square
            :target: https://pypi.python.org/pypi/drf-generators/
            :alt: Latest Version
        
        .. |license| image:: https://img.shields.io/pypi/l/drf-generators.svg?style=flat-square
            :target: https://pypi.python.org/pypi/drf-generators/
            :alt: License
        
        .. |travis| image:: https://img.shields.io/travis/Brobin/drf-generators.svg?style=flat-square
            :target: https://travis-ci.org/Brobin/drf-generators/
            :alt: Travis CI
        
        .. |django| image:: https://img.shields.io/badge/Django-1.11, 2.2,3.0-orange.svg?style=flat-square
            :target: http://djangoproject.com/
            :alt: Django 1.11, 2.2, 3.0
        
        .. |drf| image:: https://img.shields.io/badge/DRF-3.11-orange.svg?style=flat-square
            :target: http://www.django-rest-framework.org/
            :alt: DRF 3.11
        
Keywords: API REST framework generate scaffold
Platform: UNKNOWN
Classifier: Environment :: Web Environment
Classifier: Framework :: Django :: 1.11
Classifier: Framework :: Django :: 2.2
Classifier: Framework :: Django :: 3.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Internet :: WWW/HTTP