{"id":21165,"library":"django-tastypie","title":"django-tastypie","description":"A flexible & capable API layer for Django. Current version 0.15.1, maintained but with infrequent releases.","status":"active","version":"0.15.1","language":"python","source_language":"en","source_url":"https://github.com/django-tastypie/django-tastypie","tags":["django","api","rest","tastypie"],"install":[{"cmd":"pip install django-tastypie","lang":"bash","label":"Install django-tastypie"}],"dependencies":[{"reason":"Core dependency, tested with Django 2.2+ but works with later versions.","package":"Django","optional":false},{"reason":"Used for date/time serialization.","package":"python-dateutil","optional":false},{"reason":"Used for content-type negotiation.","package":"mimeparse","optional":false}],"imports":[{"note":"Api class lives in tastypie.api submodule.","wrong":"from tastypie import Api","symbol":"Api","correct":"from tastypie.api import Api"},{"note":"Resource base class is in tastypie.resources.","wrong":"from tastypie import Resource","symbol":"Resource","correct":"from tastypie.resources import Resource"},{"note":"","wrong":"","symbol":"ModelResource","correct":"from tastypie.resources import ModelResource"},{"note":"Fields are commonly imported this way.","wrong":"","symbol":"fields","correct":"from tastypie import fields"},{"note":"","wrong":"","symbol":"Bundle","correct":"from tastypie.bundle import Bundle"}],"quickstart":{"code":"import os\nos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')\nimport django\ndjango.setup()\n\nfrom tastypie.api import Api\nfrom tastypie.resources import ModelResource\nfrom myapp.models import MyModel\n\nclass MyModelResource(ModelResource):\n    class Meta:\n        queryset = MyModel.objects.all()\n        resource_name = 'mymodel'\n        allowed_methods = ['get', 'post', 'put', 'delete']\n        authentication = ApiKeyAuthentication()\n        authorization = DjangoAuthorization()\n\napi = Api(api_name='v1')\napi.register(MyModelResource())\n\n# Then include in urls.py as: urlpatterns = [path('api/', include(api.urls))]","lang":"python","description":"Minimal setup: define a ModelResource, register it on an Api instance, and include the urls."},"warnings":[{"fix":"Use MyModel.objects.all() instead of MyModel.objects.","message":"ModelResource.Meta.queryset is required and must be a QuerySet, not a manager.","severity":"gotcha","affected_versions":"all"},{"fix":"Add fields = ['m2m_field'] to the Meta class.","message":"Serialization of many-to-many fields requires explicit declaration in the resource fields.","severity":"gotcha","affected_versions":"all"},{"fix":"Use MIDDLEWARE_CLASSES or upgrade to 0.15.0+ which adds partial compatibility.","message":"Tastypie does NOT support Django's new-style middleware (MIDDLEWARE setting). You must use MIDDLEWARE_CLASSES if you need tastypie middleware.","severity":"gotcha","affected_versions":"<=0.14.4"},{"fix":"Use 'is_valid' or custom validation in 'obj_create'/'obj_update'.","message":"The 'dehydrate' and 'hydrate' methods are for modifying serialized/deserialized data, not for validation.","severity":"gotcha","affected_versions":"all"},{"fix":"Check docs for updated patterns; currently both work.","message":"The 'authentication' and 'authorization' params in Meta are being replaced by class-based configurations in future releases.","severity":"deprecated","affected_versions":"0.14+"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run: pip install django-tastypie","cause":"django-tastypie not installed or not in environment.","error":"ModuleNotFoundError: No module named 'tastypie'"},{"fix":"Add 'queryset = MyModel.objects.all()' to the Meta class.","cause":"Often due to missing 'queryset' in Meta class of ModelResource.","error":"AttributeError: 'NoneType' object has no attribute 'items'"},{"fix":"Use Api(api_name='v1') or pass the name parameter.","cause":"Api instantiated without api_name.","error":"ImproperlyConfigured: The 'api_name' argument must be specified."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}