Skip to content

Instantly share code, notes, and snippets.

@eofs
Created March 22, 2013 14:36
Show Gist options
  • Save eofs/5221729 to your computer and use it in GitHub Desktop.
Save eofs/5221729 to your computer and use it in GitHub Desktop.
Use of DRF Proxy's RemoteModels
from django.db import models
from rest_framework_proxy.db.models import ProxyModel
class Snippet(ProxyModel):
name = models.CharField(max_length=25)
body = models.TextField(blank=True)
@staticmethod
def get_resource_class():
return 'core.resources.SnippetResource'
from rest_framework_proxy.db import resources
from core.models import Snippet
class SnippetResource(resources.RemoteResource):
model = Snippet
auth = ('myUsername', 'myPassword')
url = 'http://localhost:8080/api/snippets/'
headers = {
'Accept': 'application/json',
}
class Meta:
result_root = 'results'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment