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
1.0.2
1.0.1
1.0.0
0.9.7
0.9.6
0.9.5
0.9.4
0.9.3
0.9.2
0.9.1
0.9.0
0.8.9
0.8.8
0.8.7
0.8.6
0.8.5
0.8.4
0.8.3
0.8.2
0.8.19
0.8.18
0.8.17
0.8.16
0.8.15
0.8.14
0.8.13
0.8.12
0.8.11
0.8.10
0.8.1
0.8.0
0.7.7
0.7.6
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.3
0.6.2
0.6.1
0.6.0
0.5.8
0.5.7
0.5.6
0.5.5
0.5.4
0.5.32
0.5.31
0.5.30
0.5.3
0.5.29
0.5.28
0.5.27
0.5.26
0.5.25
0.5.24
0.5.23
0.5.22
0.5.21
0.5.20
0.5.2
0.5.19
0.5.18
0.5.17
0.5.16
0.5.15
0.5.14
0.5.13
0.5.12
0.5.11
0.5.10
0.5.1
0.5.0
0.4.2
0.4.1
0.4.0
0.3.9
0.3.8
0.3.7
0.3.6
0.3.5
0.3.4
0.3.3
0.3.2
0.3.11
0.3.10
0.3.1
0.3.0
0.21.3
0.21.2
0.21.1
0.21.0
0.20.0
0.2.6
0.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.19.9
0.19.8
0.19.7
0.19.6
0.19.5
0.19.4
0.19.3
0.19.2
0.19.10
0.19.1
0.19.0
0.18.1
0.18.0
0.17.9
0.17.8
0.17.7
0.17.6
0.17.5
0.17.4
0.17.3
0.17.2
0.17.1
0.17.0
0.16.1
0.16.0
0.15.1
0.15.0
0.14.0
0.13.0
0.12.0
0.11.0
0.10.9
0.10.8
0.10.7
0.10.6
0.10.5
0.10.4
0.10.3
0.10.2
0.10.10
0.10.1
0.10.0
0.1.9
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.12
0.1.11
0.1.10
0.1.1
0.1.0
توضیحات
Django Restframework Utils
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | drfexts-1.1.4 |
| نام | drfexts |
| نسخه کتابخانه | 1.1.4 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | aiden |
| ایمیل نویسنده | allaher@icloud.com |
| آدرس صفحه اصلی | https://github.com/aiden520/drfexts |
| آدرس اینترنتی | https://pypi.org/project/drfexts/ |
| مجوز | Apache-2.0 |
drfexts
=======
[](https://github.com/aiden520/drfexts/blob/master/LICENSE)
[](https://pypi.python.org/pypi/drfexts)

[](https://www.djangoproject.com/)
[](https://www.django-rest-framework.org)
[](https://app.travis-ci.com/aiden520/drfexts)
[](https://github.com/ambv/black)
**Extensions for Django REST Framework**
Installation
------------
``` {.bash}
$ pip install drfexts
```
Usage
-----
*views.py*
``` {.python}
from rest_framework.views import APIView
from rest_framework.settings import api_settings
from drfexts.viewsets import ExportMixin
class MyView (ExportMixin, APIView):
...
```
Ordered Fields
--------------
By default, a `CSVRenderer` will output fields in sorted order. To
specify an alternative field ordering you can override the `header`
attribute. There are two ways to do this:
1) Create a new renderer class and override the `header` attribute
directly:
> ``` {.python}
> class MyUserRenderer (CSVRenderer):
> header = ['first', 'last', 'email']
>
> @api_view(['GET'])
> @renderer_classes((MyUserRenderer,))
> def my_view(request):
> users = User.objects.filter(active=True)
> content = [{'first': user.first_name,
> 'last': user.last_name,
> 'email': user.email}
> for user in users]
> return Response(content)
> ```
2) Use the `renderer_context` to override the field ordering on the
fly:
> ``` {.python}
> class MyView (APIView):
> renderer_classes = [CSVRenderer]
>
> def get_renderer_context(self):
> context = super().get_renderer_context()
> context['header'] = (
> self.request.GET['fields'].split(',')
> if 'fields' in self.request.GET else None)
> return context
>
> ...
> ```
Labeled Fields
--------------
Custom labels can be applied to the `CSVRenderer` using the `labels`
dict attribute where each key corresponds to the header and the value
corresponds to the custom label for that header.
1\) Create a new renderer class and override the `header` and `labels`
attribute directly:
> ``` {.python}
> class MyBazRenderer (CSVRenderer):
> header = ['foo.bar']
> labels = {
> 'foo.bar': 'baz'
> }
> ```
Pagination
----------
Using the renderer with paginated data is also possible with the new
[PaginatedCSVRenderer]{.title-ref} class and should be used with views
that paginate data
For more information about using renderers with Django REST Framework,
see the [API
Guide](http://django-rest-framework.org/api-guide/renderers/) or the
[Tutorial](http://django-rest-framework.org/tutorial/1-serialization/).
Running the tests
-----------------
To run the tests against the current environment:
``` {.bash}
$ ./manage.py test
```
### Changelog
1.0.0
-----
- Initial release
## Thanks
[](https://www.jetbrains.com/?from=drfexts)
نیازمندی
| مقدار | نام |
|---|---|
| >=3.2 | django |
| >=1.12.3 | django-storages |
| >=21.1 | django-filter |
| >=3.12.4 | djangorestframework |
| >=21.3.1 | pip |
| >=2.1.1 | djangorestframework-csv |
| >=3.0.9 | openpyxl |
| >=3.8.0 | orjson |
| >=0.5.3 | django-currentuser |
| >=0.9.8 | drf-flex-fields |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.8,<4.0.0 | Python |
نحوه نصب
نصب پکیج whl drfexts-1.1.4:
pip install drfexts-1.1.4.whl
نصب پکیج tar.gz drfexts-1.1.4:
pip install drfexts-1.1.4.tar.gz