Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

wrapper django rest framework

Project Description
# 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
Release History

Release History

This version
History Node

1.7.3

History Node

1.7.2

History Node

1.7.1

History Node

1.7.0

History Node

1.6.9

History Node

1.6.8

History Node

1.6.7

History Node

1.6.6

History Node

1.6.5

History Node

1.6.4

History Node

1.6.3

History Node

1.6.2

History Node

1.6.1

History Node

1.6

History Node

1.5

History Node

1.4

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_hipster_api-1.7.3.tar.gz (9.1 kB) Copy SHA256 Checksum SHA256 Source Dec 22, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting