Do you perform regular maintenance on your application? You can simplify periodic cron tasks by creating custom manage.py commands.
- [Narrator] There are times when you want…to create your own custom management commands.…One of the most common reasons is…to have a scheduled task that runs at regular intervals.…Let's start with the custom manage.py commands.…When I use sessions, I notice over time…my sessions table gets big.…In recent versions of Django there's…a built in command to clean this up for us,…but we'll create our own.…For example if you have special rules you want to apply.…In order to create a management command…you have to create an app and then enable it…in your installed apps.…Then inside the app you need to…create a folder called management.…
It needs to be a valid python model…so that means you do need the end .py…Inside that folder you need to…create another folder called commands.…It also needs to be a module so…it also needs the end .py…Then each file in this folder that…does not begin with an underscore…can contain a single management command.…You see here, I've created two.…One is called clean up and the other is send reports.…
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