0

I have a requirement whereby sometimes our database engine goes down and I need to automate a certain procedure to through django's command line. Am trying to write a code that would run to perform some reporting and start up some services and I need to run in from django context so i can use django's library and project setting.

Any ways, is there a way to develop a command line that can be executed without checking if database exists or perhaps i can trap the exception? any ideas?

1 Answer 1

1

NVM, I looked at source code for the command "shell" and saw "requires_model_validation" parameter. I used it in my command and it went through, here is an example

class Command(NoArgsCommand):
    args = '<No arguments>'
    help = 'This command will init the database.'
    requires_model_validation = False

    def handle(self, *args, **options):
        try:
            print 'ss'
        except Exception :
            raise CommandError('Cannot find default database settings')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.