How to schedule a cron on pythonanywhere server

If you have hosted your Django app on pythonanywhere.com server and you want to schedule a cron job on the server to execute some task periodically ( daily or hourly) then this article is for you.

cron jobs are executed after a fixed interval of time, repetitively until stopped explicitly. This may come handy if you want to send bulk mails every hour or you may want to take a backup of your database or basically anything you want to perform periodically.

Continue reading “How to schedule a cron on pythonanywhere server”

How to create management commands in Django

 

You must have used createsuperuser command in your django application at one or other time. If not then I am sure you must have used makemigrations or migrate commands in your project. Yes? Yes.

So these commands, also called as management commands are used to execute some piece of code from command line. In this article I will tell you how to create your own command.

Why do you need management command:

First thing that comes to your mind after reading above paragraph is that why do even I need management command in my project.

Lets say you have a project where you need to perform some task periodically. For example : updating database column after fetching data from some other server, sending lots of mails, taking backup of your database etc etc.

Continue reading “How to create management commands in Django”