|
1 | 1 | Django Rest Framework Mongoengine |
2 | | -=============================== |
| 2 | +================================= |
3 | 3 |
|
4 | | -***Mongoengine*** support for ***Django Rest Framework***. |
5 | | - |
6 | | -# DRF 3 |
7 | | -Starting from `version 2.0`, this package will be developed using `DRF 3.0` and higher. |
8 | | - |
9 | | -# DRF 2 |
10 | | -If you want to use `DRFME` with `DRF 2`, you should `version 1.*`. Development will be continued on `drf_2_support` branch. |
| 4 | +The package provides [mongoengine](mongoengine.org) support for [django-rest-framework](https://github.com/tomchristie/django-rest-framework) |
11 | 5 |
|
12 | 6 | ## Documentation |
13 | | -See full documentation [here](https://pythonhosted.org/django-rest-framework-mongoengine/) |
14 | | -### DocumentSerializer |
15 | | -`DocumentSerializer` works just like as `DRF Model Serializer`. Your model fields are converted to relevant serializer fields automatically. If you want custom behavior, you can use `nested serializers`. |
16 | | -```Python |
17 | | -from rest_framework_mongoengine.serializers import DocumentSerializer |
18 | 7 |
|
19 | | -class BlogSerializer(DocumentSerializer): |
20 | | - class Meta: |
21 | | - model = Blog |
22 | | - fields = ('id', 'author', 'name', 'date_created') |
23 | | -``` |
24 | | -### DynamicDocumentSerializer |
25 | | -A `DocumentSerializer` for dynamic documents. |
26 | | -### EmbeddedDocumentSerializer |
27 | | -`EmbeddedDocumentSerializer` is used to customize `EmbeddedDocument` behavior, and make `validations` accurately. It is mentioned extensively on the [documentation](https://pythonhosted.org/django-rest-framework-mongoengine/serializers/#embeddeddocumentserializer) |
28 | | -### Generic Views |
29 | | -`Generic Views` are named exactly the same as `DRF Generic Views`. |
| 8 | +For full documentation, usage and examples refer to [DRF manuals](http://www.django-rest-framework.org/). |
| 9 | + |
| 10 | +The features and differences of this package are described in [API documentation](http://umutbozkurt.github.io/django-rest-framework-mongoengine/) |
30 | 11 |
|
31 | | -Just make sure you are using `DRFME Generics`. |
| 12 | +## Requirements |
32 | 13 |
|
33 | | -`from rest_framework_mongoengine import generics` |
| 14 | +* Django == 1.* |
| 15 | +* djangorestframework == 3.* |
| 16 | +* mongoengine == 0.10.* | 0.9.* |
| 17 | +* blinker == 1.* (for mongoengine referencefields to work) |
| 18 | +* With mongoengine 0.10: pymongo == 3.* |
| 19 | +* With mongoengine 0.9: pymongo == 2.* |
34 | 20 |
|
35 | 21 | ## Installation |
| 22 | + |
| 23 | +### from pypi |
| 24 | + |
36 | 25 | `pip install django-rest-framework-mongoengine` |
37 | 26 |
|
38 | | -**Note:** You might consider using a specific version. |
| 27 | +### from github |
| 28 | + |
| 29 | +* download [some release from github](https://github.com/umutbozkurt/django-rest-framework-mongoengine/releases), unpack somewhere. |
| 30 | +* copy subdir `unpacked_path/rest_framework_mongoengine` into your django project or inside python path |
| 31 | +* or, install using `pip unpacked_path` |
| 32 | + |
| 33 | +### do not use git clone! |
| 34 | + |
| 35 | +It may contain non-working code. |
39 | 36 |
|
40 | | -***For clarity:*** |
41 | | -- DRF2 support: `pip install "django-rest-framework-mongoengine<2.0"` |
42 | | -- DRF3 support: `pip install "django-rest-framework-mongoengine>=2.0"` |
| 37 | +## Usage |
43 | 38 |
|
| 39 | +### Include the packages in Django settings. |
44 | 40 |
|
45 | | -Don't forget to add the package to installed apps. |
46 | 41 | ```Python |
47 | 42 | INSTALLED_APPS = ( |
48 | 43 | ... |
| 44 | + 'rest_framework' |
49 | 45 | 'rest_framework_mongoengine', |
| 46 | + ... |
50 | 47 | ) |
51 | 48 | ``` |
52 | 49 |
|
| 50 | +### Import modules |
| 51 | + |
| 52 | +Use corresponding classes from this package in place of original DRF stuff. Refer to API documentation. |
| 53 | + |
| 54 | +## Releases |
| 55 | + |
| 56 | +### Current release |
| 57 | + |
| 58 | +Intended to match DRF API. The major and minor version number matches supported version of DRF. |
| 59 | + |
| 60 | +### Old releases |
| 61 | + |
| 62 | +Releases 2.x were not well compatible with DRF and mongoengine. Current code is mostly refactored and reimplemented. |
| 63 | + |
| 64 | +### Ancient releases |
| 65 | + |
| 66 | +Releases 1.x were developed to work with `DRF 2`. This branch is no longer supported. |
| 67 | +Documentation available [here](https://github.com/umutbozkurt/django-rest-framework-mongoengine/blob/drf_2_support/README.md) |
| 68 | + |
53 | 69 | ## Maintainers |
54 | 70 |
|
55 | 71 | @qwiglydee |
|
0 commit comments