Closed pisipite closed 4 years ago
Acceptance Criteria (may be a bit more loose):
To implement REST API there are some libraries mentioned here: https://github.com/humiaozuzu/awesome-flask
Ideally models should be registered with moonsheep and everything else should work out of the box.
from django.db import models
from moonsheep import register
@register.model(api=True, export_exclude_fields=[])
class Declaration(models.Model):
...
Effect:
All @register.model
parameters should be optional.
@catileptic I'm working on it now.
Implementing an API for domain model is as simple as:
from moonsheep.api import AppApi
urlpatterns = [
# url(r'^admin/', admin.site.urls),
# url(r'^moonsheep/', include('moonsheep.urls')),
# ...
url(r'^api/opora/', include(AppApi('opora').urls)),
]
AppApi
scans for all domain models defined in your app (passed in the param) and generates URL for each using Django Rest Framework. Rest Framework gives you a nice html interface to play with requests, discovery (listing of all endpoints). Using moonsheep-opora example: http://localhost:8000/api/opora/
to be able to export the data into different formats.