Sometimes you want to modify the data before it goes out to the API. Tastypie makes it easy to add or customize the data returned from the API.
- View Offline
- [Narrator] What we demonstrated in the last video…will work with most apps.…Angular JS, Backbone and other tools…can understand how to deal with APIs…of this sort pretty easily.…But sometimes it's more efficient…if the server can just tweak the data a little bit…or allow you to do a little work on the server…before sending the data.…In this video I'll show you how to do…more advanced queries with TastyPie.…Tastypie has a dehydrate cycle,…which essentially means that it takes…the data from a model or some other resource…and prepares it to be serialized for the API.…We're gonna customize that to…separate the year out into its own field…so that we can work with it more easily.…
We're also gonna customize the filtering…so that we can view only the…albums released in a certain year.…We'll start by adding two extra imports.…The first is InvalidFilterError,…so that we can raise an exception in case of a bad request.…And then we'll also grab datetime,…since we'll be working with years.…We're going to add three methods to our album API.…
Django is one of the world's leading web development platforms. This Python web framework makes your app building experience smoother, faster, and easier. It is a key feature behind the success of many start-ups across the world, including Instagram and Nextdoor. This course introduces next-level advanced concepts to help you build your own professional-grade Django applications.
Author Kevin Veroneau starts off by explaining how class-based views—a powerful, but often poorly understood feature—work in Django. Then learn how to create custom middleware to help organize frequently used code. Have you ever wanted to build a complete RESTful API? Find out how to do just that, starting with a basic read-only API and then adding key-based authentication to allow the full range of CRUD functionality. Plus, discover how to use model managers and the Q method to make it easier to get the data we need to our views and clients.
For the finishing touches, dive into the details of caching to improve application performance, and then add custom management commands to help automate routine tasks.
- Extending class-based views
- Creating custom class-based views
- Managing your database with middleware
- Creating template filters and tags
- Building a RESTful API
- Modeling advanced database relationships and queries
- Using a model manager for your application