0

我不知道如何在资源中定义我的外部数据库(沙发数据库)的 url。我有这个:

类用户资源(资源):

username=fields.CharField(attribute='username')
firstName=fields.CharField(attribute='firstName')
lastName=fields.CharField(attribute='lastName')
gender=fields.CharField(attribute='gender')
status=fields.IntegerField(attribute='status')
date=fields.DateTimeField(attribute='date')

class Meta:
    object_class = ??
    resource_name = 'users/list'
    always_return_data = True
    authorization= Authorization()

def get_object_list(self, request):
   ...            
       return results

def obj_get_list(self, request=None, **kwargs):
   # Filtering disabled for brevity...
   return self.get_object_list(request)
4

1 回答 1

0
class UserResource(ModeslResource)
    class Meta:
    queryset = UserModel.objects.all().using('dbname')
于 2013-03-08T14:36:45.247 回答