How to Write Management commands In Python/Django Applicaton


First we need to create project as well as app

Inside the app >  we write the management commands.

>Project
   >Project
   >App
      >managements
          >commands
              >__init__.py
             >FIlename.py

          >__init__.py
      >migrations
          >__init__.py
          >views.py
          >models.py


Inside the Filename.py we write the code. as per the below strutuer.

from django.core.management.base import BaseCommand

def add():
  pass

def sum():
  pass
class Command(BaseCommand):
    help = "Cammand to load data"
    def handle(self, *args, **kwargs):
       add()
       sum()
       more......



To run this code we need to edit the configurations.

Comments

Popular posts from this blog

How to get Full URL or get absolute url In Django

How To Convert Html File/URL/String Into Image Using Python

ERR: error parsing query: found influx, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line