Skip to main content

Django-docopt-command allows you to write Django commands using the docopt library.

Project description

Django docopt command

Build Status Version

Coverage Status Requirements Status


Django-docopt-command allows you to write Django commands using the docopt library. This means that you can define commands using usage strings.


class Command(DocOptCommand):
	# This usage string defines the command options:
	docs = "Usage: command <option1> <option2> [--flag1]"

	def handle_docopt(self, arguments):
		# arguments contains a dictionary with the options

Django-docopt-command is tested with Django 1.11-2.2 and Python 2.7, 3.5-3.7 and is hosted on github.

Note that version 0.3.0 also supports Django 1.8 - 1.10.


See the testproject/docopt_example in the django-docopt-command github repository.


Install django-docopt-command.

pip install django-docopt-command

Step 1 - management command

Write a Django custom management command, as described in Writing custom django-admin commands.

Step 2 - inherit from DocOptCommand

class Command(DocOptCommand):

Step 3 - add a docs string

class Command(DocOptCommand):
	docs = "Usage: command <option1> <option2> [--flag1]"

Step 4 - override handle_docopt

class Command(DocOptCommand):
	docs = "Usage: command <option1> <option2> [--flag1]"

	def handle_docopt(self, arguments):
		option1 = arguments['option1']
		option2 = arguments['option2']


Django-docopt-command is licensed under the Apache 2.0 License.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-docopt-command, version 0.5.0
Filename, size File type Python version Upload date Hashes
Filename, size django_docopt_command-0.5.0-py3.6.egg (3.2 kB) File type Egg Python version 3.6 Upload date Hashes View
Filename, size django_docopt_command-0.5.0-py3-none-any.whl (3.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django-docopt-command-0.5.0.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page