Changeset 6082
- Timestamp:
- 09/09/07 21:29:42 (1 year ago)
- Files:
-
- django/branches/newforms-admin (modified) (1 prop)
- django/branches/newforms-admin/AUTHORS (modified) (1 diff)
- django/branches/newforms-admin/django/core/management/base.py (modified) (6 diffs)
- django/branches/newforms-admin/django/core/management/commands/createcachetable.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/management/commands/dumpdata.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/management/commands/flush.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/management/commands/loaddata.py (modified) (2 diffs)
- django/branches/newforms-admin/django/core/management/commands/reset.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/management/commands/runfcgi.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/management/commands/runserver.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/management/commands/shell.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/management/commands/syncdb.py (modified) (2 diffs)
- django/branches/newforms-admin/django/core/management/commands/test.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/management/commands/testserver.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/management/__init__.py (modified) (2 diffs)
- django/branches/newforms-admin/django/core/servers/fastcgi.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/validators.py (modified) (7 diffs)
- django/branches/newforms-admin/django/db/models/fields/__init__.py (modified) (5 diffs)
- django/branches/newforms-admin/django/newforms/fields.py (modified) (4 diffs)
- django/branches/newforms-admin/django/views/generic/date_based.py (modified) (3 diffs)
- django/branches/newforms-admin/docs/contributing.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/django-admin.txt (modified) (14 diffs)
- django/branches/newforms-admin/docs/fastcgi.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/model-api.txt (modified) (2 diffs)
- django/branches/newforms-admin/docs/modpython.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/templates.txt (modified) (1 diff)
- django/branches/newforms-admin/tests/modeltests/model_forms/models.py (modified) (23 diffs)
- django/branches/newforms-admin/tests/regressiontests/forms/tests.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/newforms-admin
- Property svnmerge-integrated changed from /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-6050 to /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-6081
django/branches/newforms-admin/AUTHORS
r6054 r6082 81 81 Michal Chruszcz <troll@pld-linux.org> 82 82 Ian Clelland <clelland@gmail.com> 83 Russell Cloran <russell@rucus.net> 83 84 colin@owlfish.com 84 85 crankycoder@gmail.com django/branches/newforms-admin/django/core/management/base.py
r6051 r6082 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/branches/newforms-admin/django/core/management/commands/createcachetable.py
r5984 r6082 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/branches/newforms-admin/django/core/management/commands/dumpdata.py
r5918 r6082 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 = BaseCommand.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/branches/newforms-admin/django/core/management/commands/flush.py
r6014 r6082 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/branches/newforms-admin/django/core/management/commands/loaddata.py
r5984 r6082 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/branches/newforms-admin/django/core/management/commands/reset.py
r5918 r6082 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/branches/newforms-admin/django/core/management/commands/runfcgi.py
r5918 r6082 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/branches/newforms-admin/django/core/management/commands/runserver.py
r6051 r6082 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/branches/newforms-admin/django/core/management/commands/shell.py
r5918 r6082 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/branches/newforms-admin/django/core/management/commands/syncdb.py
r5984 r6082 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/branches/newforms-admin/django/core/management/commands/test.py
r5918 r6082 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/branches/newforms-admin/django/core/management/commands/testserver.py
r5918 r6082 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/branches/newforms-admin/django/core/management/__init__.py
r5918 r6082 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/branches/newforms-admin/django/core/servers/fastcgi.py
r4940 r6082 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/branches/newforms-admin/django/core/validators.py
r5918 r6082 10 10 11 11 import urllib2 12 from django.conf import settings13 from django.utils.translation import ugettext as _, ugettext_lazy, ungettext14 from django.utils.functional import Promise, lazy15 from django.utils.encoding import force_unicode16 12 import re 17 13 try: … … 19 15 except ImportError: 20 16 from django.utils._decimal import Decimal, DecimalException # Python 2.3 17 18 from django.conf import settings 19 from django.utils.translation import ugettext as _, ugettext_lazy, ungettext 20 from django.utils.functional import Promise, lazy 21 from django.utils.encoding import force_unicode 21 22 22 23 _datere = r'\d{4}-\d{1,2}-\d{1,2}' … … 149 150 except ValueError, e: 150 151 msg = _('Invalid date: %s') % _(str(e)) 151 raise ValidationError, msg 152 raise ValidationError, msg 152 153 153 154 def isValidANSIDate(field_data, all_data): … … 252 253 except: # urllib2.URLError, httplib.InvalidURL, etc. 253 254 raise ValidationError, _("The URL %s is a broken link.") % field_data 254 255 255 256 def isValidUSState(field_data, all_data): 256 257 "Checks that the given string is a valid two-letter U.S. state abbreviation" … … 381 382 382 383 def __call__(self, field_data, all_data): 383 # Try to make the value numeric. If this fails, we assume another 384 # Try to make the value numeric. If this fails, we assume another 384 385 # validator will catch the problem. 385 386 try: … … 387 388 except ValueError: 388 389 return 389 390 390 391 # Now validate 391 392 if self.lower and self.upper and (val < self.lower or val > self.upper): … … 424 425 raise ValidationError, _("Please enter a valid decimal number.") 425 426 426 pieces = str(val). split('.')427 pieces = str(val).lstrip("-").split('.') 427 428 decimals = (len(pieces) == 2) and len(pieces[1]) or 0 428 429 digits = len(pieces[0]) django/branches/newforms-admin/django/db/models/fields/__init__.py
r6056 r6082 1 import datetime 2 import os 3 import time 4 try: 5 import decimal 6 except ImportError: 7 from django.utils import _decimal as decimal # for Python 2.3 8 1 9 from django.db import get_creation_module 2 10 from django.db.models import signals … … 13 21 from django.utils.encoding import smart_unicode, force_unicode, smart_str 14 22 from django.utils.maxlength import LegacyMaxlength 15 import datetime, os, time16 try:17 import decimal18 except ImportError:19 from django.utils import _decimal as decimal # for Python 2.320 23 21 24 class NOT_PROVIDED: … … 381 384 def save_form_data(self, instance, data): 382 385 setattr(instance, self.name, data) 383 386 384 387 def formfield(self, form_class=forms.CharField, **kwargs): 385 388 "Returns a django.newforms.Field instance for this database Field." … … 784 787 if data: 785 788 getattr(instance, "save_%s_file" % self.name)(data.filename, data.content, save=False) 786 789 787 790 def formfield(self, **kwargs): 788 791 defaults = {'form_class': forms.FileField} 789 # If a file has been provided previously, then the form doesn't require 792 # If a file has been provided previously, then the form doesn't require 790 793 # that a new file is provided this time. 791 794 if 'initial' in kwargs: … … 917 920 if 'db_index' not in kwargs: 918 921 kwargs['db_index'] = True 919 Field.__init__(self, *args, **kwargs) 920 921 def get_manipulator_field_objs(self): 922 return [oldforms.TextField] 922 super(SlugField, self).__init__(*args, **kwargs) 923 923 924 924 class SmallIntegerField(IntegerField): django/branches/newforms-admin/django/newforms/fields.py
r5918 r6082 191 191 except DecimalException: 192 192 raise ValidationError(ugettext('Enter a number.')) 193 pieces = str(value). split('.')193 pieces = str(value).lstrip("-").split('.') 194 194 decimals = (len(pieces) == 2) and len(pieces[1]) or 0 195 195 digits = len(pieces[0]) … … 354 354 self.filename = filename 355 355 self.content = content 356 356 357 357 def __unicode__(self): 358 358 """ … … 397 397 raise ValidationError(ugettext(u"Upload a valid image. The file you uploaded was either not an image or a corrupted image.")) 398 398 return f 399 399 400 400 class URLField(RegexField): 401 401 def __init__(self, max_length=None, min_length=None, verify_exists=False, … … 527 527 """ 528 528 A Field that aggregates the logic of multiple Fields. 529 529 530 530 Its clean() method takes a "decompressed" list of values, which are then 531 531 cleaned into a single value according to self.fields. Each value in django/branches/newforms-admin/django/views/generic/date_based.py
r5918 r6082 1 import datetime 2 import time 3 1 4 from django.template import loader, RequestContext 2 5 from django.core.exceptions import ObjectDoesNotExist … … 4 7 from django.db.models.fields import DateTimeField 5 8 from django.http import Http404, HttpResponse 6 import datetime, time7 9 8 10 def archive_index(request, queryset, date_field, num_latest=15, … … 77 79 raise Http404 78 80 if make_object_list: 79 object_list = queryset.filter(**lookup_kwargs) .order_by(date_field)81 object_list = queryset.filter(**lookup_kwargs) 80 82 else: 81 83 object_list = [] django/branches/newforms-admin/docs/contributing.txt
r5984 r6082 122 122 English than in code. Indentation is the most common example; it's hard to 123 123 read patches when the only difference in code is that it's indented. 124 125 * When creating patches, always run ``svn diff`` from the top-level 126 ``trunk`` directory -- i.e., the one that contains ``django``, ``docs``, 127 ``tests``, ``AUTHORS``, etc. This makes it easy for other people to apply 128 your patches. 124 129 125 130 * Attach patches to a ticket in the `ticket tracker`_, using the "attach file" django/branches/newforms-admin/docs/django-admin.txt
r6051 r6082 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
