Check something before django server starts

Posted by Vijay Shankar Kalyanaraman on Stack Overflow See other posts from Stack Overflow or by Vijay Shankar Kalyanaraman
Published on 2012-03-28T23:17:47Z Indexed on 2012/03/28 23:29 UTC
Read the original article Hit count: 179

Filed under:

I am running my api behind a django server and say I have a one time token that is needed by the django application and used through out its existence until the process quits. To check if I can proceed and serve requests (using the django server) I need to validate this token against a database entry. Now, I can have a script that hits the db, then issues the run server command if the token is valid. But if the db used by the django applications change, I will have to change the script also to point to the same db.

Is there a way I can pass this token into the runserver command as an additional parameter (along with hostname:port) and validate this before django serves any requests? How can I access this parameter that is sent into ./manage.py runserver.

Thanks.

© Stack Overflow or respective owner

Related posts about django