From the course: Python for JavaScript Developers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Enhancing endpoints with mixins

Solution: Enhancing endpoints with mixins - Python Tutorial

From the course: Python for JavaScript Developers

Start my 1-month free trial

Solution: Enhancing endpoints with mixins

(upbeat music) - [Instructor] So, how did it go? This task may have been more of a challenge because it's in the context of a larger code base, which means there's a bit more noise to deal with. So let's take a look at the solution. So I have the ItemsMixin, and that UsersMixin which is in place for a database. But then on line 38, I defined a list logic which has that get method, that both item and user are going to need. Then online 43, I did something similar. I took the detailed logic and put that into a mixin. And for the rest of that it's kind of like our soup and salad recipes. It's just putting things together. So let's scroll down a bit, and on line 50, you'll see I have an ItemListView, which again inherits from APIView, but then it takes ListMixin as well as ItemsMixin. And there's passed to say there's no code block here, because it's basically a composition of different mixins and classes. Then online…

Contents