Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 1.01 KB

README.md

File metadata and controls

36 lines (27 loc) · 1.01 KB

restedorm

I needed a way to map a rest-api in a project I'm working on, I like the orm way and wanted to give it a try

Usage

Add an endpoint (ugly and will change)

import restedorm
restedorm.BASE_URL = 'http://yoururl/'

The way to use restedorm is just as straight forward as defining a model:

from restedorm.abstract_base import RestObject
from restedorm.decorators import Endpoint

@Endpoint('users')
class User(RestObject):
    id = int
    name = str
    bio = str
    twitter = str
    linkedin = str
    state = str
    last_login = datetime
    skype = str
    email = str
    website_url = str
    date_joined = datetime
    issues = list('full.path.to.model.extending.RestObject') M2M
    issues = 'full.path.to.model.extending.RestObject' Foreignkey

And then start querying it (bare in mind that the api needs to be able to handle filter and so on for this to work):

user = User.objects.get(id=1)
users = User.objects.filter()