Skip to content

Wegoshare/django-rest-client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Rest Client

Django Rest Client App

Quick start

  1. Add "django_rest_client" to INSTALLED_APPS:
INSTALLED_APPS = {
... 'django_rest_client'

}

  1. Define settings:

LISTS_NUMBER_OF_ENTRIES_PER_PAGE = X

API_BASE_URL = 'http:\api-url.net'

  1. Example of RestClient:
class AuthApiClient(RestClientBase):

namespace = '<base-endpoint>'

def login(self, email, password):
data = {
'authId': email, 'password': password

}

response = self.post(endpoint='/auth', data=data)

if response.status_code == 200:
return True
elif response.status_code == requests.codes.unauthorized:
return

self.handle(response)

  1. Example of Model
class ExampleMappedFieldDataObject(MappedFieldDataObject):
class Meta:
field_mapping = {
'attribute_one': 'someKey', 'attribute_two': lambda x: x.get('anotherKey') or False

} reverse_field_mapping = {

'someKey': 'attribute_one', 'anotherKey': 'attribute_two'

} filters_mapping = {

'someKey': 'filter_one',

}

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%