A Django Manager for HTTP data using the well-known Django ORM interface
This package is not in PyPI. We'll add as soon as possible
Imagine that you have an endpoint http://my.api.com/companies
that shows a list of Companies
:
[
{
"name": "Company 1",
"id": 1,
"nameOfFounder": "Marcos Cardoso",
"birthday": "1990-07-30",
},
{
"name": "Company 2",
"id": 2,
"nameOfFounder": "Samuel Medeiros Cardoso",
"birthday": "1955-04-26",
}
]
The first step is create a model class that inherit from HTTPModel
, and setup the desired attributes and override the HTTPModel.HTTPMeta
class:
from django_http_model.models import HTTPModel, fields
class Company(HTTPModel):
name = fields.HTTPField()
id = fields.HTTPField()
founder = fields.HTTPField(field_name="nameOfFounder")
birthday = fields.HTTPDateField(date_fmt="%Y-%m-%d")
class HTTPMeta(HTTPModel.HTTPMeta):
url = "http://my.api.com/companies"
Now you can call the manager methods from Company
model: Company.objects.all()
, for example.
delete/0
all/0
get/1
pk: int
delete/1
pk: int
- Relations between
HTTPModel
- Relations between
HTTPModel
anddjango.db.models.Model
- More manager's methods:
save/0
filter/1
[?]pks: list
- HTTPModel, HTTPManager, HTTPField and HTTPDateField implemented
- HTTPManager:
all/0
,get/1
anddelete/1
method implemented - HTTPModel:
delete/0
method implemented