O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

24.5.2 The createuser and createsuperuser Commands

The createuser and createsuperuser commands are much more involved than the createtag command, but the principle is the same. In /user/management/commands/ we create a file called createuser.py for the createuser command and a file called createsuperuser.py for the createsuperuser command. In both files, we declare a Command class, which inherits from BaseCommand. Our goal is to define the add_arguments() and handle() methods.

We take this a step further and imitate the createsuperuser.py command supplied by auth. The command has two ways of working: interactively and non-interactively. If you checkout a commit in the git repo from before Chapter 22, you’ll be able to see this for yourself. To ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required