Skip to main content
# hipster_api
wrapper django rest framework

## Применение
Для удобства использования restapi в вашем проекте

Подключение
```python
INSTALLED_APPS = (
...
'rest_framework',
'hipster_api',
)
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), '..', 'templates').replace('\\', '/'),
)
```


## Пример views
```python
from hipster_api import fields as hfields
from hipster_api.views import HView


class QuestsView(HView):
"""
Работа с постами
"""

class Fields(object):
fields = hfields.FieldsListResponse(verbose_name=u'Список полей через запятую', methods=['get'])
offset = hfields.IntegerLarger(default=0, larger=0, glt=True, methods=['get'])
limit = hfields.IntegerLarger(default=20, larger=0, methods=['get'])
active = hfields.IntegerList(default=u'0,1', methods=['get'])

name = hfields.String(verbose_name=u'Название поста', default=u'', methods=['put'])
description = hfields.String(verbose_name=u'Название поста', default=u'', methods=['put'])

def get(self, request, format=None):
"""
Получение постов
:public:
"""
fields = ['id'] + self.objects.fields
posts = Post.objects.values(*fields).filter(active__in=self.objects.active)[self.objects.offset:self.objects.limit]

return Response(quests)

def put(self, request, format=None):
"""
Создание поста
:private только админа:
"""

Post(name=self.objects.name, description=self.objects.description).save()
return Response(status=202)

```

### запросы
```
GET /api/v1/posts.json?fields=name
GET /api/v1/posts.json?fields=name,description

PUT /api/v1/posts.json
name = 'тест'
description = 'тес тест'

```

## Собираем документацию
`python manage.py hipster_api_doc`

### вывод в шаблоне

```html
{% block container %}
<div class="row">
<div class="col-md-9" role="main">
{% if file_name %}
{% include file_name %}
{% endif %}
</div>
<div class="col-md-3" role="complementary">
<nav class="affix">
<ul class="nav">
{% include 'docs/menu2.html' %}
</ul>

</nav>
</div>
</div>
{% endblock %}
```

`file_name` - должен путь к доке `docs/files/...`

# реализованные поля

* [x] String
* [x] StringList
* [x] FieldsListResponse
* [x] Integer
* [x] IntegerLarger
* [x] IntegerList
* [x] IntegerLess
* [x] Float
* [x] FloatLess
* [x] FloatLarger
* [x] FloatList
* [x] Boolean
* [x] DateTime
* [x] Date
* [x] JsonField

Metadata

Release files for django_hipster_api 1.7.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django_hipster_api 1.7.3
File Size Uploaded Provenance
django_hipster_api-1.7.3.tar.gz 9.1 kB Without provenance Details

Release files / django_hipster_api-1.7.3.tar.gz

Download URL django_hipster_api-1.7.3.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d0f1c27dc3becfb1d502849d3489ab00dddad6364f77ee5dab38dbf2dfb60d21
BLAKE2b-256 checksum
How to use checksums
cd6658447a0fac56b911c11b5b60f17b3782c1b9aa679208bb02939b2925de68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django_hipster_api 1.7.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page