from tastypie.resources import ModelResource
from olcc.models import Product, ProductPrice, Store

class ProductResource(ModelResource):
    class Meta:
        queryset = Product.objects.all()
        resource_name = 'product'

class ProductPriceResource(ModelResource):
    class Meta:
        queryset = ProductPrice.objects.all()
        resource_name = 'price'

class StoreResource(ModelResource):
    class Meta:
        queryset = Store.objects.all()
        resource_name = 'store'

from tastypie import fields
from tastypie.resources import ModelResource, ALL
from olcc.models import Product, ProductPrice, Store

class ProductResource(ModelResource):
    class Meta:
        queryset = Product.objects.all()
        resource_name = 'product'
        allowed_methods = ['get']
        filtering = {
            'title': ALL,
            'code': ALL,
            'proof': ALL,
            'size': ALL,
            'status': ALL,
            'on_sale': ALL,
        }

class ProductPriceResource(ModelResource):
    product = fields.ToOneField(ProductResource, 'product')

    class Meta:
        queryset = ProductPrice.objects.all()
        resource_name = 'price'
        allowed_methods = ['get']
        filtering = {
            'product': ['exact'],
        }

class StoreResource(ModelResource):
    class Meta:
        queryset = Store.objects.all()
        resource_name = 'store'
        allowed_methods = ['get']

Tweak the tastypie resource configuration.
Tweak the tastypie resource configuration.

+ from tastypie import fields
- from tastypie.resources import ModelResource
+ from tastypie.resources import ModelResource, ALL
  from olcc.models import Product, ProductPrice, Store
  
  class ProductResource(ModelResource):
      class Meta:
          queryset = Product.objects.all()
          resource_name = 'product'
+         allowed_methods = ['get']
+         filtering = {
+             'title': ALL,
+             'code': ALL,
+             'proof': ALL,
+             'size': ALL,
+             'status': ALL,
+             'on_sale': ALL,
+         }
  
  class ProductPriceResource(ModelResource):
+     product = fields.ToOneField(ProductResource, 'product')
+ 
      class Meta:
          queryset = ProductPrice.objects.all()
          resource_name = 'price'
+         allowed_methods = ['get']
+         filtering = {
+             'product': ['exact'],
+         }
  
  class StoreResource(ModelResource):
      class Meta:
          queryset = Store.objects.all()
          resource_name = 'store'
+         allowed_methods = ['get']
  
Tweak the tastypie resource configuration.
## Code Before:
from tastypie.resources import ModelResource
from olcc.models import Product, ProductPrice, Store

class ProductResource(ModelResource):
    class Meta:
        queryset = Product.objects.all()
        resource_name = 'product'

class ProductPriceResource(ModelResource):
    class Meta:
        queryset = ProductPrice.objects.all()
        resource_name = 'price'

class StoreResource(ModelResource):
    class Meta:
        queryset = Store.objects.all()
        resource_name = 'store'

## Instruction:
Tweak the tastypie resource configuration.
## Code After:
from tastypie import fields
from tastypie.resources import ModelResource, ALL
from olcc.models import Product, ProductPrice, Store

class ProductResource(ModelResource):
    class Meta:
        queryset = Product.objects.all()
        resource_name = 'product'
        allowed_methods = ['get']
        filtering = {
            'title': ALL,
            'code': ALL,
            'proof': ALL,
            'size': ALL,
            'status': ALL,
            'on_sale': ALL,
        }

class ProductPriceResource(ModelResource):
    product = fields.ToOneField(ProductResource, 'product')

    class Meta:
        queryset = ProductPrice.objects.all()
        resource_name = 'price'
        allowed_methods = ['get']
        filtering = {
            'product': ['exact'],
        }

class StoreResource(ModelResource):
    class Meta:
        queryset = Store.objects.all()
        resource_name = 'store'
        allowed_methods = ['get']
