from tastypie.authorization import DjangoAuthorization
from tastypie import fields
from tastypie.resources import ModelResource, ALL_WITH_RELATIONS
from quotations.apps.quotations import models as quotations_models
from quotations.libs.auth import MethodAuthentication
from quotations.libs.serializers import Serializer


class BaseMeta(object):
    serializer = Serializer()
    authentication = MethodAuthentication()
    authorization = DjangoAuthorization()


class AuthorResource(ModelResource):

    class Meta(BaseMeta):
        queryset = quotations_models.Author.objects.all()
        resource_name = 'authors'


class QuotationResource(ModelResource):
    author = fields.ForeignKey(AuthorResource, 'author', full=True)

    class Meta(BaseMeta):
        queryset = quotations_models.Quotation.objects.all()
        resource_name = 'quotations'
        filtering = {
            'text': ['contains'],
            'author': ALL_WITH_RELATIONS
        }

from tastypie.authorization import DjangoAuthorization
from tastypie import fields
from tastypie.resources import ModelResource, ALL_WITH_RELATIONS
from quotations.apps.quotations import models as quotations_models
from quotations.libs.auth import MethodAuthentication
from quotations.libs.serializers import Serializer


class BaseMeta(object):
    serializer = Serializer()
    authentication = MethodAuthentication()
    authorization = DjangoAuthorization()


class AuthorResource(ModelResource):

    class Meta(BaseMeta):
        queryset = quotations_models.Author.objects.all()
        resource_name = 'authors'
        filtering = {
            'name': ['exact', 'contains']
        }


class QuotationResource(ModelResource):
    author = fields.ForeignKey(AuthorResource, 'author', full=True)

    class Meta(BaseMeta):
        queryset = quotations_models.Quotation.objects.all()
        resource_name = 'quotations'
        filtering = {
            'text': ['contains'],
            'author': ALL_WITH_RELATIONS
        }

Allow filtering by author name
Allow filtering by author name

  from tastypie.authorization import DjangoAuthorization
  from tastypie import fields
  from tastypie.resources import ModelResource, ALL_WITH_RELATIONS
  from quotations.apps.quotations import models as quotations_models
  from quotations.libs.auth import MethodAuthentication
  from quotations.libs.serializers import Serializer
  
  
  class BaseMeta(object):
      serializer = Serializer()
      authentication = MethodAuthentication()
      authorization = DjangoAuthorization()
  
  
  class AuthorResource(ModelResource):
  
      class Meta(BaseMeta):
          queryset = quotations_models.Author.objects.all()
          resource_name = 'authors'
+         filtering = {
+             'name': ['exact', 'contains']
+         }
  
  
  class QuotationResource(ModelResource):
      author = fields.ForeignKey(AuthorResource, 'author', full=True)
  
      class Meta(BaseMeta):
          queryset = quotations_models.Quotation.objects.all()
          resource_name = 'quotations'
          filtering = {
              'text': ['contains'],
              'author': ALL_WITH_RELATIONS
          }
  
Allow filtering by author name
## Code Before:
from tastypie.authorization import DjangoAuthorization
from tastypie import fields
from tastypie.resources import ModelResource, ALL_WITH_RELATIONS
from quotations.apps.quotations import models as quotations_models
from quotations.libs.auth import MethodAuthentication
from quotations.libs.serializers import Serializer


class BaseMeta(object):
    serializer = Serializer()
    authentication = MethodAuthentication()
    authorization = DjangoAuthorization()


class AuthorResource(ModelResource):

    class Meta(BaseMeta):
        queryset = quotations_models.Author.objects.all()
        resource_name = 'authors'


class QuotationResource(ModelResource):
    author = fields.ForeignKey(AuthorResource, 'author', full=True)

    class Meta(BaseMeta):
        queryset = quotations_models.Quotation.objects.all()
        resource_name = 'quotations'
        filtering = {
            'text': ['contains'],
            'author': ALL_WITH_RELATIONS
        }

## Instruction:
Allow filtering by author name
## Code After:
from tastypie.authorization import DjangoAuthorization
from tastypie import fields
from tastypie.resources import ModelResource, ALL_WITH_RELATIONS
from quotations.apps.quotations import models as quotations_models
from quotations.libs.auth import MethodAuthentication
from quotations.libs.serializers import Serializer


class BaseMeta(object):
    serializer = Serializer()
    authentication = MethodAuthentication()
    authorization = DjangoAuthorization()


class AuthorResource(ModelResource):

    class Meta(BaseMeta):
        queryset = quotations_models.Author.objects.all()
        resource_name = 'authors'
        filtering = {
            'name': ['exact', 'contains']
        }


class QuotationResource(ModelResource):
    author = fields.ForeignKey(AuthorResource, 'author', full=True)

    class Meta(BaseMeta):
        queryset = quotations_models.Quotation.objects.all()
        resource_name = 'quotations'
        filtering = {
            'text': ['contains'],
            'author': ALL_WITH_RELATIONS
        }
