Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: skip system check when running custom command

Tags:

python

django

I've added a custom management command to an application developed using Django 1.6.11. This command, let's call it initdb, performs a set of particualr actions:

  • Checks whenever a database and user from settings.py exist and if not create them, set appropriate character sets, grants access, etc.
  • Performs syncdb
  • Loads particular database dump

In other words, it's very handy for quick database initialization from total zero.

Now, I'm migrating to Django 1.8.5 and one thing I've noticed is that, before almost every command, Django automatically executes check command from new system check framework, which among other stuff checks if database/user form settings.py exist. That leads to a situation when I can't run my custom command because automatic check throws exceptions that there is no access to database (indeed, my custom command should create it).

Is there any way to force skipping automatic check that Django makes, at least in custom management command?

like image 631
gdbcore Avatar asked Oct 26 '15 15:10

gdbcore


1 Answers

Yes, and this is fully documented; set the requires_system_checks attribute to False in your Command subclass.

like image 84
Daniel Roseman Avatar answered Nov 15 '22 03:11

Daniel Roseman