An open API service indexing awesome lists of open source software.

https://github.com/lkiarest/django-utils

Django related utility tools
https://github.com/lkiarest/django-utils

Last synced: 12 months ago
JSON representation

Django related utility tools

Awesome Lists containing this project

README

          

# django-utils
Django related utility tools

### encoder
JSON serialization helper, decorate model class: add `to_json` method automatically.

```python
# models.py
from utils.encoder import json_encoder

@json_encoder('id', 'name', 'age')
class User(Model):
name = Model.CharField(max_length=44)
 age = Model.IntegerField()


# controller
users = User.objects.all()
return HttpResponse(json.dumps([user.to_json() for user in users])
```