|
3 | 3 | Django classes to make your models, managers, and querysets serializable, with built-in support for related objects in ~100 LoC (shorter than this README!)
|
4 | 4 |
|
5 | 5 |
|
| 6 | +## Installation |
| 7 | + |
| 8 | +`pip install django-serializable-model` |
| 9 | + |
| 10 | +It is expected that you already have Django installed |
| 11 | + |
| 12 | +### Compatibility |
| 13 | + |
| 14 | +_This was originally used in an older Django 1.5 codebase with Python 2.7._ |
| 15 | + |
| 16 | +<br> |
| 17 | + |
| 18 | +Should work with Django 1.5-1.9 with Python 2.7. |
| 19 | + |
| 20 | +Likely works with Django 1.10 and 1.11, though not 100% sure that `._meta.fields` usage works the same way in these. |
| 21 | + |
| 22 | +Will have some problems with Django 2.0 as the Manager's `use_for_related_fields` has been removed. |
| 23 | + |
| 24 | +`2to3` shows that there is nothing to change, so should be compatible with Python 3.x |
| 25 | + |
| 26 | +Have not confirmed if this works with earlier versions of Django or Python. |
| 27 | + |
| 28 | +<br> |
| 29 | + |
| 30 | +Please submit a PR or file an issue if you have a compatibility problem or have confirmed compatibility on versions. |
| 31 | + |
| 32 | + |
6 | 33 | ## Usage
|
7 | 34 |
|
8 | 35 | Simplest use case, just implements the `.serialize()` function on a model:
|
@@ -172,27 +199,6 @@ In order to recurse over relations / joins, it accepts the same arguments as the
|
172 | 199 | I'd encourage you to read the source code, since it's shorter than this README :)
|
173 | 200 |
|
174 | 201 |
|
175 |
| -## Compatibility |
176 |
| - |
177 |
| -_This was originally used in an older Django 1.5 codebase with Python 2.7._ |
178 |
| - |
179 |
| -<br> |
180 |
| - |
181 |
| -Should work with Django 1.5-1.9 with Python 2.7. |
182 |
| - |
183 |
| -Likely works with Django 1.10 and 1.11, though not 100% sure that `._meta.fields` usage works the same way in these. |
184 |
| - |
185 |
| -Will have some problems with Django 2.0 as the Manager's `use_for_related_fields` has been removed. |
186 |
| - |
187 |
| -`2to3` shows that there is nothing to change, so should be compatible with Python 3.x |
188 |
| - |
189 |
| -Have not confirmed if this works with earlier versions of Django or Python. |
190 |
| - |
191 |
| -<br> |
192 |
| - |
193 |
| -Please submit a PR or file an issue if you have a compatibility problem or have confirmed compatibility on versions. |
194 |
| - |
195 |
| - |
196 | 202 | ## Backstory
|
197 | 203 |
|
198 | 204 | This library was built while I was working on [Yorango](https://github.com/Yorango)'s ad-hoc API. Writing code to serialize various models was complex and quite tedious, resulting in messy spaghetti code for many of our API methods. The only solutions I could find online were the [Django Full Serializers](http://code.google.com/p/wadofstuff/wiki/DjangoFullSerializers) from [wadofstuff](https://github.com/mattimustang/wadofstuff) as well as some recursive `model_to_dict` snippets online -- none of which gave the option for customizable whitelists and blacklists on a per Model basis.
|
|
0 commit comments