Pybites Podcast

#113 - Django Plugin Recommendations by Antonio Melé | Top 10 Picks for Web Development

Julian Sequeira & Bob Belderbos

He's back! Django by Example book author Antonio Melé 😍

Not only that, we did this interview in person at a cafeteria on the beach 🏖

In this episode he shares his 10 favorite Django plugins 💪 💡

1. Django Debug Toolbar

2. Django REST Framework

3. Django Channels

4. Django Celery

5. Django Extensions

6. Django allauth and social-auth

7. Django Import Export

8. Django Sentry

9. Django Easy Thumbnails / Imagekit

10. Django-parler

Of course we also asked him what he's reading at the moment:

- Nudge

Connect with Antonio:
- LinkedIn
- Pybites Slack

Antonio's previous Pybites podcast episode is number 89

And last but not least, get Antonio's epic Django book, you won't regret it!

Hello and welcome to the Pibytes podcast, where we talk about Python career and mindset. We're your hosts. I'm Julian Sequeira. And I am Bob Baldeboz. If you're looking to improve your python, your career, and learn the mindset for success, this is the podcast for you. Let's get started. Welcome back to Pyewise, YouTube, and today a very special podcast episode with Antonio Millay, the Django four by example guy and good friend. So he's back to talk about ten Django plugins. A pretty concise episode that doesn't take longer than 25 minutes and you can expect a lot of value. And we actually did it together here at the beach. So that was just extraordinary. But at one penalty hit that the audio is not 100% great. So if you listen to this in your earbuds and when walking around, maybe switch over to YouTube, see us there on the beach talking together. And hopefully that makes up for a little bit loss of the sounds because we were in a cafeteria, so there was, of course, some background noise. We did have the microphone. You don't see it on the screen, but we had that plugged in above our heads. So that's just a warning up front. But yeah, nonetheless, Antonio, as always, provides great value. It was awesome to have him back and learn from one of the Django experts and really nice guy. Right. Enjoy. Hello, everybody. Welcome back to the Pie Bytes podcast. I'm here with Antonio Malev. He's back. I'm back. I was here episode 89 of the PY Byz podcast and of course we had him get him back and here in real person at some exotic beach in Spain. In person this time. Yeah, yeah. So post pandemic, we can meet again and we decided to do, yeah. Have a bit of setting here. It's really nice. Much better than. Right. Working remotely. Django developer, Django developer life. Yeah. So today we're going to talk Django, of course, because if you don't know, Antonio Malaysia of Django by example, 1234, maybe five soon. And so last episode we already dove into his career and what he does. So I refer back to 89, this episode. Just going to keep it quite technical. Right. We're going to talk Django plugins and I think that's it. Right, that's it. Short technical episode and it goes through some different Django plugins that I usually use in my. And hopefully, hopefully those are also useful for you guys. Yeah, maybe before we kick it off, you want to share any win or something? Cool. You're working on. Well, I'm now preparing the outline for Django five by example. So hopefully that comes out when Django five is released. But still some work to update the book radio edition language. I'm very positive about it. Yeah, kudos man. Like that book, you keep it like super up to date. And the Django release cycle, it seems like it's going faster every time. It's going faster and faster. So it goes more challenging to read the book as fast as. Awesome, awesome. Yeah, no, it's really fun. I've spoken up about the book. Get it? It's super practical. Like we like PI by, it's project based and the older and less so. Yeah, let's dive in. So we have ten plugins today. So your favorites. And let's dive straight in. Right. So number one, numero uno. Number one is debug toolbar. It's difficult to configure. No, it's easy to configure, but almost everybody runs into some problems with a statics or with, with something in order to show the toolbar. But still it's really useful tool to debug Django and especially when you are debugging SQL queries from your views, but as well in your templates, because sometimes you start accessing related objects and templates and you don't realize that you can do the n plus one problem and you can go and it's really useful to pack SQL, but as well it gives information about the cpu load and templates used during the rendering and the signals that have been triggered. So that's really useful. Yeah, it's a must have for any Django developer, right? Definitely. Especially for the SQL queries. And I think around this episode I will actually do a little demo on YouTube on the n plus one problem, what it means and how to solve it and hence how you can debug it with the toolbar. Maybe also video on how to install the toolbar because pretty meta, right? Like ten minutes ago we were actually debugging the debug toolbar. Exactly. That's the first step, debugging the debug toolbar. It's not very obvious. Yeah. But yeah. Must have no discussion about it. I think so, yeah. You want to move on to number two? Number two is rest framework, I think. Well, nowadays everybody uses build stress APIs, have to build any kind of JSON based API for deployments. And it's a really useful tool because you can basically create restful endpoints around your models and it gives you everything you need from serializers, validators, you can also nest related objects. It gives you functionality, format authentication, permissions, everything you need. So basically you can very quickly end up with restful API and also implement any custom API methods that you might need. Really useful. Plus you get also things like caching and event trusting, which I think is also very useful to protect Abis against attacks. So you can also set up your API through the and festivals. But yeah, no, and I think when you go Django, right, like fast API. Fast API is the big API framework right now. Right. But if you have to use Django then yeah, it's probably better to go with Django rest. Yeah, yeah. I mean you would go for fast API if you're building something very API oriented and you want to be very faster if you can. If you want as well to take advantage of the other functionality that Django provides you with, then rest framework is the choice. Awesome. Cool. So number three, I think you had Django channels that's relatively new, right? That's relatively new, true. But now Django provides asynchronous functionality. SDA and Django channels provide you with additional functionality that Django async capabilities. It's very easy to implement things like websockets, subscribe to channels and then send information real time. And you can use redis as channel there to send messages. So I also recommend redis with django not only for caching but as well use all the functionality redis provides with specific field types that are very useful for development. Plus as well you could use as exchange messages with. Yeah, that's good to know because we're following your book with a client and so setting up chat we definitely need address and I think you also need Dufnet for deployment then, right? Yeah, Daftnet helps with the SD Sci server. Yeah, you will need any kind of sci server. So yeah, channels are school and chat, but it does involve a bit more of the tooling around it. Yeah, cool. Four celery for celery celery celery is a muster veggies. I think seller is a must as well in any Django application because as soon as you want to send an email to a client or you don't want to stop the view execution because of that, or any other asynchronous tasks that you want to execute, then you need to use celery as very soon. And you can either use tweet q backends like rabbitmq or redis. And it's really cool because you can also implement redive policies for fail tasks very easily. And there's this other package called flower to monitor redis that's, sorry, salary tasks. That's also very useful to see what's happening behind the scenes. And you can also schedule tasks with celery bit. So it's very useful not only for asynchronous tasks, but also to schedule tasks that have to be executed. Network ran. Yeah, that's really cool. And inevitably with Django you hit a view that's going to be slow because some work and then you pushing it to a background task is super cool technology. For example, many people use Django signals to implement their logic. When you say something has to happen, whenever something else happens, right, and you get this event driven functionality, but signals, many people mistakenly think that signals are performant. It's not asynchronous, it's synchronous, basically the execution of Django signals. So if you have to use Django signals to do anything asynchronously, then you need to create sequence task with celery and then run your task with later on your signal. Resavo cool. So it's really useful for those. Yeah, we use it for ironscribe, right. When we are transcribing a video that takes some time, so we push it on the task queue and then, you know, you get an email when it's done, you're going to run into it with Django. Yeah. Bigger projects, right? Five Django, five Django stations. Django extensions has been out there for many, many years already and I initially used it to graph models. With graphit there's a specific command to create and graph your own or all of your models. It's very useful when you have identification with a lot of different apps and models, and it's a good way to keep your documentation updated about the models that you're using, etcetera. So it's to just create draft of all your models with just one command. And then you get as well things like run server plus, which allows you to run the Django development server with an SL certificate that's automatically generated. So you get to access your Django development server through HTTPs, which you may need sometimes. For example, if you are doing the things like social authentication, certain platforms might need an HTTPs URL for the callback or anything like that. So then you can test your local deployment with HTTPs. Of course you should never use transfer for your production environment, but it's a good functionality to have as well. Yeah. Was there also the plugin that comes with shell plus so that you have a more robust Django shell. Yeah, true. Yeah, that's a very useful one. Okay, cool. So six Django, all auth, social auth number six. Yeah, we have, well for number six I have two options. One is jungle health, the other one is social health. Both give you social authentication backends with auth two. And yeah, very useful if you want to implement social authentication in your platform. And yeah, both, I've been using one or the one, but both are very useful to implement social application with Google, with any kind of auth service. Yeah, because even, even without the social platforms getting the login and sign up to work, I mean it's all provided by general vendors included, but sometimes it still is not obvious how to wire it up. And with all outs I find it easier to get that all out of the way also like the flow of, you know, sign up with an email confirmation. Right. That's not something you want to typically build on scratch. Exactly. And OAuth gives you that as well? Very easily, yeah. Cool. Then number seven is Django import export. I've been using it for a while previously. I always built my own tool for importing and exporting information into Django models. Well, it's actually a very good exercise to try to build your own data exporter, for example for the Django administration side, because then you can, you can dig into how models are built dynamically and how to access all the model fields, etcetera, and build a tool that's actually flexible and not for a specific model. Right. But rather than pluggable, but yeah. So if you want to build your own, you can do it. If you need a quick tool to import or export data in bulk, the Django import export is super useful and you get also the actions for the Django admin side, it really helps social standard that you could use in almost all your projects. Whenever you have users that need to export data, import data, that's good to know because I usually use or Django commands or Django fixtures, so generating JSON files and importing them. But this plugin gives you more like UI around it. It's integrated into admin, right? Exactly. So yeah, you get both methods that you can use, but you can also integrate into the admin side. And I find it very useful for admin users very easily they start asking for how can I export this to excel or to a CSV file. So you could also use it as standard for all your young or admin models and provides default sports functionalities or import functionalities in all of your admin models, in the admin. Very useful. Yeah. All right. Number eight. Number eight is sentry. Sentry is a tool I love. It provides you with error monitoring, very useful production environments, very easy to set up, and you have essentially both as an open source tool and there's some kind of free hosted service in the cloud. And yeah, the introduction is really simple and you get all the information you need for all the errors. So you get the trace back, you get all the context in each of the steps, all the context variables, all the information the user has, put them in the request, all of that. Plus you can as well hide certain information from data tracking, et cetera. So it's really, really useful. Yeah, it's awesome because as much as we test and stuff, there will always be edge cases and in production as the debug is not turned, true user gets a flying 500 page. Right, exactly. You get an email. Exactly. And you get an email and sometimes you wonder what the problem is and you don't have the proper information. So you need to try to replicate the issue. So it's really useful to start with stack phrase from the very beginning and then the plugin side of it here is that it takes two lines of code to basically, yeah. And then you can play as well with providing the version sentry every time you deploy any version. So you can also know exactly which version that you deployed has this error, etcetera. Gotcha. Cool. All right, two more. Nine. Okay. We have also easy thumbnails and imagekit. Those two are very useful to generate thumbnails automatically for image fields and to edit images automatically. A reuse for tool to do the thumbnailing in automated manner and efficient manner. And then you don't really need to worry about that anymore as soon as you add to your project. Right. Because then first time the image thumbnail is requested, it gets generated, second time it's right there. So it's already served. And a really useful tool because you don't want to spend a lot of time building your own steinmailing functionality in order to generate images, then remove the images when, et cetera. So really, really useful for inside using images that have been uploaded by users, etcetera. Yeah. And often you just don't know that that's out there because I would be very tempted to Piv install pillow start to write my own function. Exactly. No, there's a plugin, I saw that in your book and like, wow, that's smart. Just pivot install and one line of code and it does a perfect job reinventing the wheel. Yeah, awesome. All right. And then number ten. And number ten also Django parlor. Django Parlor allows you to translate your models and it's really useful because you can define translatable fields and then it provides you also with the orm query sets functionality where you can perform query sets based on the current active language or filter by a specific language, etcetera. So it's very useful when you have to store information in multiple languages and it provides you with all the tools to generate the associated models in order to store the different fields in different languages. So really useful when you have to work with internationalization, localization, et cetera. Right? Yeah, I've not used it, but definitely had one or two clients that I want to have the models in various languages and it's very tempting to then folks. And then pooks underscore. Yes. And books underscore it. Right. And make like duplicated models, but then it's not dry. Right. So again, have to plug in, take care of it and. Exactly. Just focus on the english models basically. Exactly. And then when you retrieve information and you render your templates by default, you get it automatically in the language that is currently active for the user. So it's very useful and saves you a lot of time rather than building it yourself. And as well, you get the full admin functionality, so you get multiple tabs to edit the model in the different languages and you can play with certain things that are not translatable as all the pins that are translatable. And it gives a lot of flexibility. Cool. I have two questions and we didn't prepare it, so I got to put you on the spot. So these, you know you have dependency hell, right? With pinning those plugins, do you pin them or do you leave them open for operates? How do you manage those? So I usually pin them, yeah. I would say most of the time I usually get just to make sure that they're not a compatibility issue with other plugins. Right, exactly. Or requirements. Exactly, exactly. Just to make sure that permits. And then eventually I upgrade, et cetera. Okay. And the other question just occurred to me. Right. So maybe it's a dumb question, but is there like plugins, I mean, they're great not reinventing the wheel, but sometimes, you know, the maintainability of it. Is there also a case in Django, one example where you don't use a plugin, you said like I definitely going to write them. So it depends a bit on like for example, if there's something that will be very core to what you are building. Right. And sometimes it's a plugin for that, but you maybe don't need as much flexibility or as much functionality as the provides, but you need the questions to be more performant or anything like that. I'm thinking, for example, about an event system. There was a time I built an event system myself because I, unlike this devices that I had, were not as performant as what I needed. And on the other hand it would be very core to my application. So in that case I built it myself. But of course, many times you have to think about, yeah, can I just start using a plugin? And I start with that and then eventually I might build my own functionality if I need, or if you have to build on your own directly, I would say most cases you can start with a plugin. Maybe you can always use the plugin forever and only to add more functionality or make it more performant for a specific scenarios, etcetera. Then build on your own. Yeah, that's a great point. So get it working first and fast and then you can always later swap it out. And one conservation then is the performance, right? Need to go almost like a python and c plugins. C extend, yeah, exactly. Yeah. Because again, well, the plugin, you know, in the end you need to cover a lot of different use cases. So basically the plugin starts getting bigger. Many times not covered, different use cases requested by users, et cetera. And it's true that at some point it gives a lot of flexibility, but on the other hand, it might not cover very well your specific use case, or it might not be as performant as it you would like, you would like or anything like that. But this is a decision that you wouldn't take at the very beginning, at the very end. Start with any plugin that gives you functionality or only build on your own. If it's really something simple, fast. Yeah, you don't have to worry if your SaaS app only has one user that deployed. There's not much to speak about. Cool. Now this is super helpful. Thanks for sharing and anything I left out or you want to add to this or. No, I think, I hope, well, this list was useful for and you, hopefully someone might get another plugin that they knew about. So yeah, hope it's useful for all viewers. I definitely learned a couple of new things, so thanks. Yeah. Lastly, you want to share a book? Are you reading? Yeah, so I'm reading Nudge by Richard Baller and Cassen. And it's about nudge theory. They won a Nobel Prize I think with this theory where you help people take better decisions, but not enforcing those decisions to them, but allowing them to maintain individual freedom and individual choice so they feel in control of their decisions. So it's very interesting because it says things like, when you want people to eat healthier, you don't have to just prohibit a certain type of food, but you might encourage better food and still let the people take their own decision. I want to eat this around doing that. It's really interesting because it provides you with these tools to improve the decisions individuals take while maintaining individual freedom. Was that based on Kahneman's work? Yeah, psychology read. Cool. I think that's it. Thanks for hopping on again. Thank you very much, Bob, for having me. Thanks for everything you do for the Django community and, you know, teaching so many people. It's tremendously valuable. And, yeah, it was great being here today, physically. Yeah. Like, also, I think a shout out. Right? Like, or maybe a last piece of advice, like, go. Go to meetup. Go hang out. Exactly. Go meet the community. Conversations are deeper. When you sit down, you slow down. Right. There's just. There's more depth. It's really, really nice. So, yeah, as much as you can. Yeah. All right, well, we'll be back in the next episode. Thanks for listening and watching, and thank you very much. There it is. Here we are. All right, thank you. Thanks. Bye. We hope you enjoyed this episode. To hear more from us, go to Pibyte friends, that is Pibit es friends, and receive a free gift just for being a friend of the show and to join our thriving slack community of python programmers, go to Pibytes slash community. That's Pibit es community. We hope to see you there and catch you in the next episode.