Search code examples
djangotastypie

Django inheritance base class super


I would like to use inheritance and have all my resources inheritance from a base resource class.

You will see what I have tried so far below. My issues is I now need to add in the meta class at it seems to overwrite at the moment. How can this be done?

class BasedModelResource(ModelResource):
    class Meta:
        authentication = ApiKeyAuthentication()
        authorization = UserObjectsOnlyAuthorization()



class AccountResource(BasedModelResource):
    """
    Account Object Resource
    """
    class Meta:
        queryset = Account.objects.all()
        resource_name = 'account'

Solution

  • There is a workaround:

    Resource Meta Inheritance

    Also look at: Tastypie Meta Inheritance