Tips every Django developer should know
This first tip that have this is like one of the main things that I think of is like it comes with these building block pieces that say Flask Impure Pyramid and. Bass APN. What just don't come with like Admin back ends Yup. That's where we're going to start off. So Django clearly comes at batteries included and some people actually don't like that because they've under rule their own and they think itself. I happen to like their preferences and yeah, one of those well-known building blocks as the admin interface at and it's it's pretty impressive. But a few lines of code you. You can just add your model, an avid pie file, and you have to complete crowd interface, which is probably pretty end user. But as a maintain earth, this site it's it's pretty convenient and it's also very easy to extend it. So for example, taking admin class here, you can define some search fields. which makes those field searchable. You can have even have out a complete fields which they integrated the jobless Ritz. You can override to get crazy set and. Yeah. It's a nice way of inheriting from the Admin Dots Model Admin blasts Yeah. So it comes out of the box just. Kind of think of it as like. Google sheets or something for your database, right? Right. Where each table is like a tab or a sheet and sit in the workbook or whatever the terminology of Google sheets is. But the task. The bottom writes something I mean not necessarily stimuli. But that idea that you have like a grid over top of it. But what you're telling me is I can go into rive special classes that are tied to the various. Tables the models more specifically in it lets you search different aspects of it. Lets you cool. Auto completion. You could also say like limit how many items come back in your search results per page. So you don't get a million or something like that, right? Yeah. Do a list filter, for example, and then certain columns at the right side of the page. You can filter on them by clicking. Just. With one nine of coach. So this does raise some Cole functionality and I think, maybe in the show notes, we can link to a Django adleman cookbook, I use a loss which has like the hands. On. I. Might have mentioned before actually on pie down the vice then the umbrella from that book. That's like fifty pages and. Yeah Very. Workable. Super Bowl. Another thing you can do is you can write a function called get query set and actually do things like be joyner, do a joined queries against other things. Otherwise you may it up with like the N plus one problem of Orum's were doing queer than everything that comes back. You have to do more queries per item to try to fill out the details, I will talk about that in in one of the tips. Yeah. Yeah. Awesome. That's super cool. Let's see what else you want to say about that I. You know I was it. You think it might have been you either you or damn baiter. baiter from real python talking about using this to actually trigger events as you interact with this adman was that you think that was me. Yeah. Yeah. Yeah. Yeah. So tell us that's like I. think that's pretty related. Tell people by the pretty. Cool. Right. We spoke about that on Python Bites Yeah. Thank God. We did was in one of the at model self variety safe method, and then the object plus created, and only then do a certain action. He likes emailing people in Hindsight. That's probably better to do it a salary task by it's an example how you can override those methods and do certain things. Yeah. Pretty easily. Yeah very cool. All right remember to or magic. Yeah. Well, Dan go comes with its own orem object relational napper and it's kind of a proxy today. So you don't have to ride s all yourself although i. Am such a fan. I'm saying, well, you worked at, Oracle, didn't you? Fan of orange actually or in the nurse sequel world maybe od M.'s or or some. are might not necessarily make sense, but you know there's so many issues you can run into if you don't use parameters, queries, little bobby tables, and all those issues and just like if you get the rock queries back and you pull different values sometimes you forget to convert this thing to an integer and it's just a string that has an energy in it that sort of. All these little weird edge cases right now you're as. With. Orum's at kind of. Like a layer that just separates like how your data should be transformed I. Really Love It. I, think it's great. I know one hundred percent work all the time. Right? There's places where it doesn't. But that's not as you know like most the time it's a it's a beautiful thing and it's it's a nice obstruction and it's way easier to use and more elegant.