Instruction: Describe how to create and use custom management commands in a Django project.
Context: This question tests the candidate's familiarity with Django's command-line utilities and their capability to extend functionality with custom commands.
Official answer available
Preview the opening of the answer, then unlock the full walkthrough.
To start, custom management commands in Django require a specific structure within an application. You create a management/commands directory within your application directory. This structure tells Django to look for custom commands here. Each command you want to create will have its own Python file within this directory.
For instance, if we're creating a command named do_something, you would first ensure your application structure looks something like this:...
easy
medium
hard
hard
hard