Changeset 6075
- Timestamp:
- 09/09/07 16:57:59 (11 months ago)
- Files:
-
- django/trunk/django/core/management/base.py (modified) (6 diffs)
- django/trunk/django/core/management/commands/createcachetable.py (modified) (1 diff)
- django/trunk/django/core/management/commands/dumpdata.py (modified) (1 diff)
- django/trunk/django/core/management/commands/flush.py (modified) (1 diff)
- django/trunk/django/core/management/commands/loaddata.py (modified) (2 diffs)
- django/trunk/django/core/management/commands/reset.py (modified) (1 diff)
- django/trunk/django/core/management/commands/runfcgi.py (modified) (1 diff)
- django/trunk/django/core/management/commands/runserver.py (modified) (1 diff)
- django/trunk/django/core/management/commands/shell.py (modified) (1 diff)
- django/trunk/django/core/management/commands/syncdb.py (modified) (2 diffs)
- django/trunk/django/core/management/commands/test.py (modified) (1 diff)
- django/trunk/django/core/management/commands/testserver.py (modified) (1 diff)
- django/trunk/django/core/management/__init__.py (modified) (2 diffs)
- django/trunk/django/core/servers/fastcgi.py (modified) (1 diff)
- django/trunk/docs/django-admin.txt (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/management/base.py
r6028 r6075 1 import django 1 2 from django.core.exceptions import ImproperlyConfigured 2 3 from django.core.management.color import color_style 4 import itertools 5 from optparse import make_option, OptionParser 3 6 import sys 4 7 import os 8 from traceback import print_exc 5 9 6 10 class CommandError(Exception): … … 9 13 class BaseCommand(object): 10 14 # Metadata about this command. 15 option_list = ( 16 make_option('--settings', 17 help='The Python path to a settings module, e.g. "myproject.settings.main". If this isn\'t provided, the DJANGO_SETTINGS_MODULE environment variable will be used.'), 18 make_option('--pythonpath', 19 help='A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".'), 20 ) 11 21 help = '' 12 22 args = '' … … 19 29 def __init__(self): 20 30 self.style = color_style() 31 32 def get_version(self): 33 """ 34 Returns the Django version, which should be correct for all built-in 35 Django commands. User-supplied commands should override this method. 36 """ 37 return django.get_version() 38 39 def usage(self): 40 usage = '%prog [options] ' + self.args 41 if self.help: 42 return '%s\n\n%s' % (usage, self.help) 43 else: 44 return usage 45 46 def create_parser(self, prog_name): 47 return OptionParser(prog=prog_name, 48 usage=self.usage(), 49 version=self.get_version(), 50 option_list=self.option_list) 51 52 def print_help(self, args): 53 parser = self.create_parser(args[0]) 54 parser.print_help() 55 56 def run(self, args): 57 parser = self.create_parser(args[0]) 58 (options, args) = parser.parse_args(args[1:]) 59 if options.settings: 60 os.environ['DJANGO_SETTINGS_MODULE'] = options.settings 61 if options.pythonpath: 62 sys.path.insert(0, options.pythonpath) 63 try: 64 self.execute(*args, **options.__dict__) 65 except Exception, e: 66 print_exc() 67 parser.print_usage() 21 68 22 69 def execute(self, *args, **options): … … 70 117 71 118 class AppCommand(BaseCommand): 72 args = ' [appname ...]'119 args = '<appname appname ...>' 73 120 74 121 def handle(self, *app_labels, **options): … … 91 138 92 139 class LabelCommand(BaseCommand): 93 args = ' [label ...]'140 args = '<label label ...>' 94 141 label = 'label' 95 142 … … 169 216 new_permissions = stat.S_IMODE(st.st_mode) | stat.S_IWUSR 170 217 os.chmod(filename, new_permissions) 171 django/trunk/django/core/management/commands/createcachetable.py
r5967 r6075 3 3 class Command(LabelCommand): 4 4 help = "Creates the table needed to use the SQL cache backend." 5 args = " [tablename]"5 args = "<tablename>" 6 6 label = 'tablename' 7 7 django/trunk/django/core/management/commands/dumpdata.py
r5898 r6075 1 1 from django.core.management.base import BaseCommand, CommandError 2 2 3 from optparse import make_option 4 3 5 class Command(BaseCommand): 6 option_list = ( 7 make_option('--format', default='json', dest='format', 8 help='Specifies the output serialization format for fixtures'), 9 make_option('--indent', default=None, dest='indent', type='int', 10 help='Specifies the indent level to use when pretty-printing output'), 11 ) 4 12 help = 'Output the contents of the database as a fixture of the given format.' 5 args = '[ --format] [--indent] [appname ...]'13 args = '[appname ...]' 6 14 7 15 def handle(self, *app_labels, **options): django/trunk/django/core/management/commands/flush.py
r6013 r6075 1 1 from django.core.management.base import NoArgsCommand, CommandError 2 2 from django.core.management.color import no_style 3 from optparse import make_option 3 4 4 5 class Command(NoArgsCommand): 6 option_list = NoArgsCommand.option_list + ( 7 make_option('--verbosity', action='store', dest='verbosity', default='1', 8 type='choice', choices=['0', '1', '2'], 9 help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'), 10 make_option('--noinput', action='store_false', dest='interactive', default=True, 11 help='Tells Django to NOT prompt the user for input of any kind.'), 12 ) 5 13 help = "Executes ``sqlflush`` on the current database." 6 args = '[--verbosity] [--noinput]'7 14 8 15 def handle_noargs(self, **options): django/trunk/django/core/management/commands/loaddata.py
r5964 r6075 1 1 from django.core.management.base import BaseCommand 2 2 from django.core.management.color import no_style 3 from optparse import make_option 3 4 import sys 4 5 import os … … 10 11 11 12 class Command(BaseCommand): 13 option_list = BaseCommand.option_list + ( 14 make_option('--verbosity', action='store', dest='verbosity', default='1', 15 type='choice', choices=['0', '1', '2'], 16 help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'), 17 ) 12 18 help = 'Installs the named fixture(s) in the database.' 13 args = " [--verbosity] fixture, fixture, ..."19 args = "fixture [fixture ...]" 14 20 15 21 def handle(self, *fixture_labels, **options): django/trunk/django/core/management/commands/reset.py
r5898 r6075 1 1 from django.core.management.base import AppCommand, CommandError 2 2 from django.core.management.color import no_style 3 from optparse import make_option 3 4 4 5 class Command(AppCommand): 6 option_list = AppCommand.option_list + ( 7 make_option('--noinput', action='store_false', dest='interactive', default=True, 8 help='Tells Django to NOT prompt the user for input of any kind.'), 9 ) 5 10 help = "Executes ``sqlreset`` for the given app(s) in the current database." 6 args = '[ --noinput] [appname ...]'11 args = '[appname ...]' 7 12 8 13 output_transaction = True django/trunk/django/core/management/commands/runfcgi.py
r5898 r6075 15 15 from django.core.servers.fastcgi import runfastcgi 16 16 runfastcgi(args) 17 18 def usage(self): 19 from django.core.servers.fastcgi import FASTCGI_HELP 20 return FASTCGI_HELP django/trunk/django/core/management/commands/runserver.py
r6022 r6075 1 1 from django.core.management.base import BaseCommand, CommandError 2 from optparse import make_option 2 3 import os 3 4 import sys 4 5 5 6 class Command(BaseCommand): 7 option_list = BaseCommand.option_list + ( 8 make_option('--noreload', action='store_false', dest='use_reloader', default=True, 9 help='Tells Django to NOT use the auto-reloader.'), 10 make_option('--adminmedia', dest='admin_media_path', default='', 11 help='Specifies the directory from which to serve admin media.'), 12 ) 6 13 help = "Starts a lightweight Web server for development." 7 args = '[ --noreload] [--adminmedia=ADMIN_MEDIA_PATH] [optional port number, or ipaddr:port]'14 args = '[optional port number, or ipaddr:port]' 8 15 9 16 # Validation is called explicitly each time the server is reloaded. django/trunk/django/core/management/commands/shell.py
r5903 r6075 1 1 from django.core.management.base import NoArgsCommand 2 from optparse import make_option 2 3 3 4 class Command(NoArgsCommand): 5 option_list = NoArgsCommand.option_list + ( 6 make_option('--plain', action='store_true', dest='plain', 7 help='Tells Django to use plain Python, not IPython.'), 8 ) 4 9 help = "Runs a Python interactive interpreter. Tries to use IPython, if it's available." 5 args = '[--plain]'6 10 7 11 requires_model_validation = False django/trunk/django/core/management/commands/syncdb.py
r5975 r6075 1 1 from django.core.management.base import NoArgsCommand 2 2 from django.core.management.color import no_style 3 from optparse import make_option 3 4 import sys 4 5 … … 9 10 10 11 class Command(NoArgsCommand): 12 option_list = NoArgsCommand.option_list + ( 13 make_option('--verbosity', action='store', dest='verbosity', default='1', 14 type='choice', choices=['0', '1', '2'], 15 help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'), 16 make_option('--noinput', action='store_false', dest='interactive', default=True, 17 help='Tells Django to NOT prompt the user for input of any kind.'), 18 ) 11 19 help = "Create the database tables for all apps in INSTALLED_APPS whose tables haven't already been created." 12 args = '[--verbosity] [--noinput]'13 20 14 21 def handle_noargs(self, **options): django/trunk/django/core/management/commands/test.py
r5913 r6075 1 1 from django.core.management.base import BaseCommand 2 from optparse import make_option 2 3 import sys 3 4 4 5 class Command(BaseCommand): 6 option_list = BaseCommand.option_list + ( 7 make_option('--verbosity', action='store', dest='verbosity', default='1', 8 type='choice', choices=['0', '1', '2'], 9 help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'), 10 make_option('--noinput', action='store_false', dest='interactive', default=True, 11 help='Tells Django to NOT prompt the user for input of any kind.'), 12 ) 5 13 help = 'Runs the test suite for the specified applications, or the entire site if no apps are specified.' 6 args = '[ --verbosity] [--noinput] [appname ...]'14 args = '[appname ...]' 7 15 8 16 requires_model_validation = False django/trunk/django/core/management/commands/testserver.py
r5912 r6075 1 1 from django.core.management.base import BaseCommand 2 2 3 from optparse import make_option 4 3 5 class Command(BaseCommand): 6 option_list = BaseCommand.option_list + ( 7 make_option('--verbosity', action='store', dest='verbosity', default='1', 8 type='choice', choices=['0', '1', '2'], 9 help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'), 10 ) 4 11 help = 'Runs a development server with data from the given fixture(s).' 5 12 args = '[fixture ...]' django/trunk/django/core/management/__init__.py
r6050 r6075 19 19 """ 20 20 Calls the given command, with the given options and args/kwargs. 21 21 22 22 This is the primary API you should use for calling specific commands. 23 23 24 24 Some examples: 25 25 call_command('syncdb') … … 53 53 return dict([(name, load_command_class(name)) for name in names]) 54 54 55 def usage(self):55 def print_help(self, argv): 56 56 """ 57 Returns a usage string, for use with optparse. 57 Returns the help message, as a string. 58 """ 59 prog_name = os.path.basename(argv[0]) 60 usage = ['%s <subcommand> [options] [args]' % prog_name] 61 usage.append('Django command line tool, version %s' % django.get_version()) 62 usage.append("Type '%s help <subcommand>' for help on a specific subcommand." % prog_name) 63 usage.append('Available subcommands:') 64 commands = self.commands.keys() 65 commands.sort() 66 for cmd in commands: 67 usage.append(' %s' % cmd) 68 print '\n'.join(usage) 58 69 59 The string doesn't include the options (e.g., "--verbose"), because 60 optparse puts those in automatically. 70 def fetch_command(self, subcommand, command_name): 61 71 """ 62 usage = ["%prog command [options]\nactions:"] 63 commands = self.commands.items() 64 commands.sort() 65 for name, cmd in commands: 66 usage.append(' %s %s' % (name, cmd.args)) 67 usage.extend(textwrap.wrap(cmd.help, initial_indent=' ', subsequent_indent=' ')) 68 usage.append('') 69 return '\n'.join(usage[:-1]) # Cut off the last list element, an empty space. 72 Tries to fetch the given subcommand, printing a message with the 73 appropriate command called from the command line (usually 74 django-admin.py or manage.py) if it can't be found. 75 """ 76 try: 77 return self.commands[subcommand] 78 except KeyError: 79 sys.stderr.write("Unknown command: %r\nType '%s help' for usage.\n" % (subcommand, command_name)) 80 sys.exit(1) 70 81 71 82 def execute(self, argv=None): 72 83 """ 73 Parses the given argv from the command line, determines which command74 to run and runs the command.84 Figures out which command is being run (the first arg), creates a parser 85 appropriate to that command, and runs it. 75 86 """ 76 87 if argv is None: 77 88 argv = sys.argv 89 try: 90 command_name = argv[1] 91 except IndexError: 92 sys.stderr.write("Type '%s help' for usage.\n" % os.path.basename(argv[0])) 93 sys.exit(1) 78 94 79 # Create the parser object and parse the command-line args. 80 # TODO: Ideally each Command class would register its own options for 81 # add_option(), but we'd need to figure out how to allow for multiple 82 # Commands using the same options. The optparse library gets in the way 83 # by checking for conflicts: 84 # http://docs.python.org/lib/optparse-conflicts-between-options.html 85 parser = OptionParser(usage=self.usage(), version=get_version()) 86 parser.add_option('--settings', 87 help='The Python path to a settings module, e.g. "myproject.settings.main". If this isn\'t provided, the DJANGO_SETTINGS_MODULE environment variable will be used.') 88 parser.add_option('--pythonpath', 89 help='A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".') 90 parser.add_option('--plain', action='store_true', dest='plain', 91 help='When using "shell": Tells Django to use plain Python, not IPython.') 92 parser.add_option('--noinput', action='store_false', dest='interactive', default=True, 93 help='Tells Django to NOT prompt the user for input of any kind.') 94 parser.add_option('--noreload', action='store_false', dest='use_reloader', default=True, 95 help='When using "runserver": Tells Django to NOT use the auto-reloader.') 96 parser.add_option('--format', default='json', dest='format', 97 help='Specifies the output serialization format for fixtures') 98 parser.add_option('--indent', default=None, dest='indent', 99 type='int', help='Specifies the indent level to use when pretty-printing output') 100 parser.add_option('--verbosity', action='store', dest='verbosity', default='1', 101 type='choice', choices=['0', '1', '2'], 102 help='Verbosity level; 0=minimal output, 1=normal output, 2=all output') 103 parser.add_option('--adminmedia', dest='admin_media_path', default='', 104 help='When using "runserver": Specifies the directory from which to serve admin media.') 105 options, args = parser.parse_args(argv[1:]) 106 107 # If the 'settings' or 'pythonpath' options were submitted, activate those. 108 if options.settings: 109 os.environ['DJANGO_SETTINGS_MODULE'] = options.settings 110 if options.pythonpath: 111 sys.path.insert(0, options.pythonpath) 112 113 # Run the appropriate command. 114 try: 115 command_name = args[0] 116 except IndexError: 117 sys.stderr.write("Type '%s --help' for usage.\n" % os.path.basename(argv[0])) 118 sys.exit(1) 119 try: 120 command = self.commands[command_name] 121 except KeyError: 122 sys.stderr.write("Unknown command: %r\nType '%s --help' for usage.\n" % (command_name, os.path.basename(argv[0]))) 123 sys.exit(1) 124 command.execute(*args[1:], **options.__dict__) 95 if command_name == 'help': 96 if len(argv) > 2: 97 self.fetch_command(argv[2], argv[0]).print_help(argv[2:]) 98 else: 99 self.print_help(argv) 100 # Special-cases: We want 'django-admin.py --version' and 101 # 'django-admin.py --help' to work, for backwards compatibility. 102 elif argv[1:] == ['--version']: 103 print django.get_version() 104 elif argv[1:] == ['--help']: 105 self.print_help(argv) 106 else: 107 self.fetch_command(command_name, argv[0]).run(argv[1:]) 125 108 126 109 class ProjectManagementUtility(ManagementUtility): django/trunk/django/core/servers/fastcgi.py
r4902 r6075 18 18 __all__ = ["runfastcgi"] 19 19 20 FASTCGI_HELP = r""" runfcgi:20 FASTCGI_HELP = r""" 21 21 Run this project as a fastcgi (or some other protocol supported 22 22 by flup) application. To do this, the flup package from 23 23 http://www.saddi.com/software/flup/ is required. 24 24 25 Usage: 26 django-admin.py runfcgi --settings=yourproject.settings [fcgi settings] 27 manage.py runfcgi [fcgi settings] 25 runfcgi [options] [fcgi settings] 28 26 29 27 Optional Fcgi settings: (setting=value) django/trunk/docs/django-admin.txt
r6050 r6075 36 36 ===== 37 37 38 ``django-admin.py action [options]`` 39 40 ``manage.py action [options]`` 41 42 ``action`` should be one of the actions listed in this document. ``options``, 43 which is optional, should be zero or more of the options listed in this 44 document. 45 46 Run ``django-admin.py --help`` to display a help message that includes a terse 47 list of all available actions and options. 48 49 Most actions take a list of ``appname``s. An ``appname`` is the basename of the 50 package containing your models. For example, if your ``INSTALLED_APPS`` 51 contains the string ``'mysite.blog'``, the ``appname`` is ``blog``. 52 53 Available actions 54 ================= 55 56 adminindex [appname appname ...] 38 ``django-admin.py <subcommand> [options]`` 39 40 ``manage.py <subcommand> [options]`` 41 42 ``subcommand`` should be one of the subcommands listed in this document. 43 ``options``, which is optional, should be zero or more of the options available 44 for the given subcommand. 45 46 Getting runtime help 47 -------------------- 48 49 In Django 0.96, run ``django-admin.py --help`` to display a help message that 50 includes a terse list of all available subcommands and options. 51 52 In the Django development version, run ``django-admin.py help`` to display a 53 list of all available subcommands. Run ``django-admin.py help <subcommand>`` 54 to display a description of the given subcommand and a list of its available 55 options. 56 57 App names 58 --------- 59 60 Many subcommands take a list of "app names." An "app name" is the basename of 61 the package containing your models. For example, if your ``INSTALLED_APPS`` 62 contains the string ``'mysite.blog'``, the app name is ``blog``. 63 64 Determining the version 65 ----------------------- 66 67 Run ``django-admin.py --version`` to display the current Django version. 68 69 Examples of output:: 70 71 0.95 72 0.96 73 0.97-pre-SVN-6069 74 75 Available subcommands 76 ===================== 77 78 adminindex <appname appname ...> 57 79 -------------------------------- 58 80 59 Prints the admin-index template snippet for the given app names.81 Prints the admin-index template snippet for the given app name(s). 60 82 61 83 Use admin-index template snippets if you want to customize the look and feel of … … 64 86 .. _Tutorial 2: ../tutorial02/ 65 87 66 createcachetable [tablename]88 createcachetable <tablename> 67 89 ---------------------------- 68 90 69 91 Creates a cache table named ``tablename`` for use with the database cache 70 backend. See the `cache documentation`_ for more information.92 backend. See the `cache documentation`_ for more information. 71 93 72 94 .. _cache documentation: ../cache/ … … 101 123 if you're ever curious to see the full list of defaults. 102 124 103 dumpdata [appname appname ...]125 dumpdata <appname appname ...> 104 126 ------------------------------ 105 127 106 Output to standard output all data in the database associated with the named128 Outputs to standard output all data in the database associated with the named 107 129 application(s). 108 130 109 By default, the database will be dumped in JSON format. If you want the output110 to be in another format, use the ``--format`` option (e.g., ``format=xml``).111 You may specify any Django serialization backend (including any user specified112 serialization backends named in the ``SERIALIZATION_MODULES`` setting). The113 ``--indent`` option can be used to pretty-print the output.114 115 131 If no application name is provided, all installed applications will be dumped. 116 132 117 133 The output of ``dumpdata`` can be used as input for ``loaddata``. 134 135 --format 136 ~~~~~~~~ 137 138 By default, ``dumpdata`` will format its output in JSON, but you can use the 139 ``--format`` option to specify another format. Currently supported formats are 140 listed in `Serialization formats`_. 141 142 Example usage:: 143 144 django-admin.py dumpdata --format=xml 145 146 .. _Serialization formats: ../serialization/#Serialization-formats 147 148 --indent 149 ~~~~~~~~ 150 151 By default, ``dumpdata`` will output all data on a single line. This isn't easy 152 for humans to read, so you can use the ``--indent`` option to pretty-print the 153 output with a number of indentation spaces. 154 155 Example usage:: 156 157 django-admin.py dumpdata --indent=4 118 158 119 159 flush 120 160 ----- 121 161 122 Return the database to the state it was in immediately after syncdb was162 Returns the database to the state it was in immediately after syncdb was 123 163 executed. This means that all data will be removed from the database, any 124 164 post-synchronization handlers will be re-executed, and the ``initial_data`` … … 131 171 tables that are represented by Django models and are activated in 132 172 ``INSTALLED_APPS``. 173 174 --noinput 175 ~~~~~~~~~ 176 177 Use the ``--noinput`` option to suppress all user prompting, such as 178 "Are you sure?" confirmation messages. This is useful if ``django-admin.py`` 179 is being executed as an unattended, automated script. 180 181 --verbosity 182 ~~~~~~~~~~~ 183 184 Use ``--verbosity`` to specify the amount of notification and debug information 185 that ``django-admin.py`` should print to the console. 186 187 * ``0`` means no input. 188 * ``1`` means normal input (default). 189 * ``2`` means verbose input. 190 191 Example usage:: 192 193 django-admin.py flush --verbosity=2 133 194 134 195 inspectdb … … 173 234 only works in PostgreSQL and with certain types of MySQL tables. 174 235 175 loaddata [fixture fixture ...]236 loaddata <fixture fixture ...> 176 237 ------------------------------ 177 238 178 239 Searches for and loads the contents of the named fixture into the database. 179 240 180 A *Fixture* is a collection of files that contain the serialized contents of 181 the database. Each fixture has a unique name; however, the files that 182 comprise the fixture can be distributed over multiple directories, in 183 multiple applications. 241 A *fixture* is a collection of files that contain the serialized contents of 242 the database. Each fixture has a unique name, and the files that comprise the 243 fixture can be distributed over multiple directories, in multiple applications. 184 244 185 245 Django will search in three locations for fixtures: … … 241 301 defer checking of row constraints until a transaction is committed. 242 302 243 reset [appname appname ...] 303 --verbosity 304 ~~~~~~~~~~~ 305 306 Use ``--verbosity`` to specify the amount of notification and debug information 307 that ``django-admin.py`` should print to the console. 308 309 * ``0`` means no input. 310 * ``1`` means normal input (default). 311 * ``2`` means verbose input. 312 313 Example usage:: 314 315 django-admin.py loaddata --verbosity=2 316 317 reset <appname appname ...> 244 318 --------------------------- 245 319 246 Executes the equivalent of ``sqlreset`` for the given appnames. 320 Executes the equivalent of ``sqlreset`` for the given app name(s). 321 322 --noinput 323 ~~~~~~~~~ 324 325 Use the ``--noinput`` option to suppress all user prompting, such as 326 "Are you sure?" confirmation messages. This is useful if ``django-admin.py`` 327 is being executed as an unattended, automated script. 247 328 248 329 runfcgi [options] 249 330 ----------------- 250 331 251 Starts a set of FastCGI processes suitable for use with any web server252 whichsupports the FastCGI protocol. See the `FastCGI deployment332 Starts a set of FastCGI processes suitable for use with any Web server 333 that supports the FastCGI protocol. See the `FastCGI deployment 253 334 documentation`_ for details. Requires the Python FastCGI module from 254 335 `flup`_. … … 290 371 ``0.0.0.0``. 291 372 373 --adminmedia 374 ~~~~~~~~~~~~ 375 376 Use the ``--adminmedia`` option to tell Django where to find the various CSS 377 and JavaScript files for the Django admin interface. Normally, the development 378 server serves these files out of the Django source tree magically, but you'd 379 want to use this if you made any changes to those files for your own site. 380 381 Example usage:: 382 383 django-admin.py runserver --adminmedia=/tmp/new-admin-style/ 384 385 --noreload 386 ~~~~~~~~~~ 387 388 Use the ``--noreload`` option to disable the use of the auto-reloader. This 389 means any Python code changes you make while the server is running will *not* 390 take effect if the particular Python modules have already been loaded into 391 memory. 392 292 393 Examples: 293 394 ~~~~~~~~~ … … 332 433 .. _IPython: http://ipython.scipy.org/ 333 434 334 sql [appname appname ...]435 sql <appname appname ...> 335 436 ------------------------- 336 437 337 Prints the CREATE TABLE SQL statements for the given app names.338 339 sqlall [appname appname ...]438 Prints the CREATE TABLE SQL statements for the given app name(s). 439 440 sqlall <appname appname ...> 340 441 ---------------------------- 341 442 342 Prints the CREATE TABLE and initial-data SQL statements for the given app names.443 Prints the CREATE TABLE and initial-data SQL statements for the given app name(s). 343 444 344 445 Refer to the description of ``sqlcustom`` for an explanation of how to 345 446 specify initial data. 346 447 347 sqlclear [appname appname ...]448 sqlclear <appname appname ...> 348 449 ------------------------------ 349 450 350 Prints the DROP TABLE SQL statements for the given app names.351 352 sqlcustom [appname appname ...]451 Prints the DROP TABLE SQL statements for the given app name(s). 452 453 sqlcustom <appname appname ...> 353 454 ------------------------------- 354 455 355 Prints the custom SQL statements for the given app names.456 Prints the custom SQL statements for the given app name(s). 356 457 357 458 For each model in each specified app, this command looks for the file 358 ``<appname>/sql/<modelname>.sql``, where ``<appname>`` is the given app name and459 ``<appname>/sql/<modelname>.sql``, where ``<appname>`` is the given app name and 359 460 ``<modelname>`` is the model's name in lowercase. For example, if you have an 360 461 app ``news`` that includes a ``Story`` model, ``sqlcustom`` will attempt … … 374 475 Prints the SQL statements that would be executed for the `flush`_ command. 375 476 376 sqlindexes [appname appname ...]477 sqlindexes <appname appname ...> 377 478 -------------------------------- 378 479 379 Prints the CREATE INDEX SQL statements for the given app names.380 381 sqlreset [appname appname ...]480 Prints the CREATE INDEX SQL statements for the given app name(s). 481 482 sqlreset <appname appname ...> 382 483 ------------------------------ 383 484 384 Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app names.385 386 sqlsequencereset [appname appname ...]485 Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app name(s). 486 487 sqlsequencereset <appname appname ...> 387 488 -------------------------------------- 388 489 389 Prints the SQL statements for resetting sequences for the given 390 appnames. 490 Prints the SQL statements for resetting sequences for the given app name(s). 391 491 392 492 See http://simon.incutio.com/archive/2004/04/21/postgres for more information. 393 493 394 startapp [appname]494 startapp <appname> 395 495 ------------------ 396 496 … … 398 498 directory. 399 499 400 startproject [projectname]500 startproject <projectname> 401 501 -------------------------- 402 502 … … 436 536 data files. 437 537 538 --verbosity 539 ~~~~~~~~~~~ 540 541 Use ``--verbosity`` to specify the amount of notification and debug information 542 that ``django-admin.py`` should print to the console. 543 544 * ``0`` means no input. 545 * ``1`` means normal input (default). 546 * ``2`` means verbose input. 547 548 Example usage:: 549 550 django-admin.py syncdb --verbosity=2 551 552 --noinput 553 ~~~~~~~~~ 554 555 Use the ``--noinput`` option to suppress all user prompting, such as 556 "Are you sure?" confirmation messages. This is useful if ``django-admin.py`` 557 is being executed as an unattended, automated script. 558 438 559 test 439 560 ---- 440 561 441 Discover and run tests for all installed models. See `Testing Django applications`_ for more information. 562 Runs tests for all installed models. See `Testing Django applications`_ 563 for more information. 442 564 443 565 .. _testing Django applications: ../testing/ 444 566 445 testserver [fixture fixture ...] 567 --noinput 568 ~~~~~~~~~ 569 570 Use the ``--noinput`` option to suppress all user prompting, such as 571 "Are you sure?" confirmation messages. This is useful if ``django-admin.py`` 572 is being executed as an unattended, automated script. 573 574 --verbosity 575 ~~~~~~~~~~~ 576 577 Use ``--verbosity`` to specify the amount of notification and debug information 578 that ``django-admin.py`` should print to the console. 579 580 * ``0`` means no input. 581 * ``1`` means normal input (default). 582 * ``2`` means verbose input. 583 584 Example usage:: 585 586 django-admin.py test --verbosity=2 587 588 testserver <fixture fixture ...> 446 589 -------------------------------- 447 590 … … 485 628 .. _unit tests: ../testing/ 486 629 630 --verbosity 631 ~~~~~~~~~~~ 632 633 Use ``--verbosity`` to specify the amount of notification and debug information 634 that ``django-admin.py`` should print to the console. 635 636 * ``0`` means no input. 637 * ``1`` means normal input (default). 638 * ``2`` means verbose input. 639 640 Example usage:: 641 642 django-admin.py testserver --verbosity=2 643 487 644 validate 488 645 -------- … … 491 648 and prints validation errors to standard output. 492 649 493 Available options 494 ================= 650 Default options 651 =============== 652 653 Although some subcommands may allow their own custom options, every subcommand 654 allows for the following options: 655 656 --pythonpath 657 ------------ 658 659 Example usage:: 660 661 django-admin.py syncdb --pythonpath='/home/djangoprojects/myproject' 662 663 Adds the given filesystem path to the Python `import search path`_. If this 664 isn't provided, ``django-admin.py`` will use the ``PYTHONPATH`` environment 665 variable. 666 667 Note that this option is unnecessary in ``manage.py``, because it takes care of 668 setting the Python path for you. 669 670 .. _import search path: http://diveintopython.org/getting_to_know_python/everything_is_an_object.html 495 671 496 672 --settings … … 509 685 setting ``DJANGO_SETTINGS_MODULE`` for you. 510 686 511 --pythonpath512 ------------513 514 Example usage::515 516 django-admin.py syncdb --pythonpath='/home/djangoprojects/myproject'517 518 Adds the given filesystem path to the Python `import search path`_. If this519 isn't provided, ``django-admin.py`` will use the ``PYTHONPATH`` environment520 variable.521 522 Note that this option is unnecessary in ``manage.py``, because it takes care of523 setting the Python path for you.524 525 .. _import search path: http://diveintopython.org/getting_to_know_python/everything_is_an_object.html526 527 --format528 --------529 530 Example usage::531 532 django-admin.py dumpdata --format=xml533 534 Specifies the output format that will be used. The name provided must be the name535 of a registered serializer.536 537 --help538 ------539 540 Displays a help message that includes a terse list of all available actions and541 options.542 543 --indent544 --------545 546 Example usage::547 548 django-admin.py dumpdata --indent=4549 550 Specifies the number of spaces that will be used for indentation when551 pretty-printing output. By default, output will *not* be pretty-printed.552 Pretty-printing will only be enabled if the indent option is provided.553 554 --noinput555 ---------556 557 Inform django-admin that the user should NOT be prompted for any input. Useful558 if the django-admin script will be executed as an unattended, automated559 script.560 561 --noreload562 ----------563 564 Disable the use of the auto-reloader when running the development server.565 566 --version567 ---------568 569 Displays the current Django version.570 571 Example output::572 573 0.9.1574 0.9.1 (SVN)575 576 --verbosity577 -----------578 579 Example usage::580 581 django-admin.py syncdb --verbosity=2582 583 Verbosity determines the amount of notification and debug information that584 will be printed to the console. '0' is no output, '1' is normal output,585 and ``2`` is verbose output.586 587 --adminmedia588 ------------589 590 Example usage::591 592 django-admin.py --adminmedia=/tmp/new-admin-style/593 594 Tells Django where to find the va
