Changeset 5279
- Timestamp:
- 05/17/07 13:35:22 (2 years ago)
- Files:
-
- django/branches/unicode (modified) (1 prop)
- django/branches/unicode/django/core/management.py (modified) (4 diffs)
- django/branches/unicode/django/newforms/extras/widgets.py (modified) (1 diff)
- django/branches/unicode/django/newforms/fields.py (modified) (1 diff)
- django/branches/unicode/django/newforms/forms.py (modified) (1 diff)
- django/branches/unicode/django/newforms/models.py (modified) (1 diff)
- django/branches/unicode/django/newforms/util.py (modified) (1 diff)
- django/branches/unicode/django/newforms/widgets.py (modified) (1 diff)
- django/branches/unicode/docs/contributing.txt (modified) (2 diffs)
- django/branches/unicode/docs/db-api.txt (modified) (12 diffs)
- django/branches/unicode/docs/model-api.txt (modified) (1 diff)
- django/branches/unicode/docs/syndication_feeds.txt (modified) (1 diff)
- django/branches/unicode/extras/django_bash_completion (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/unicode
- Property svnmerge-integrated changed from /django/trunk:1-5240 to /django/trunk:1-5278
django/branches/unicode/django/core/management.py
r5241 r5279 579 579 load_data(['initial_data'], verbosity=verbosity) 580 580 syncdb.help_doc = "Create the database tables for all apps in INSTALLED_APPS whose tables haven't already been created." 581 syncdb.args = '[--verbosity] [-- interactive]'581 syncdb.args = '[--verbosity] [--noinput]' 582 582 583 583 def get_admin_index(app): … … 673 673 print "Reset cancelled." 674 674 reset.help_doc = "Executes ``sqlreset`` for the given app(s) in the current database." 675 reset.args = '[-- interactive]' + APP_ARGS675 reset.args = '[--noinput]' + APP_ARGS 676 676 677 677 def flush(verbosity=1, interactive=True): … … 734 734 print "Flush cancelled." 735 735 flush.help_doc = "Executes ``sqlflush`` on the current database." 736 flush.args = '[--verbosity] [-- interactive]'736 flush.args = '[--verbosity] [--noinput]' 737 737 738 738 def _start_helper(app_or_project, name, directory, other_name=''): … … 1453 1453 sys.stderr.write(style.ERROR("Unable to serialize database: %s\n" % e)) 1454 1454 dump_data.help_doc = 'Output the contents of the database as a fixture of the given format' 1455 dump_data.args = '[--format] ' + APP_ARGS1455 dump_data.args = '[--format] [--indent]' + APP_ARGS 1456 1456 1457 1457 # Utilities for command-line script django/branches/unicode/django/newforms/extras/widgets.py
r4265 r5279 3 3 """ 4 4 5 import datetime 6 5 7 from django.newforms.widgets import Widget, Select 6 8 from django.utils.dates import MONTHS 7 import datetime8 9 9 10 __all__ = ('SelectDateWidget',) django/branches/unicode/django/newforms/fields.py
r5236 r5279 3 3 """ 4 4 5 from django.utils.translation import ugettext6 from django.utils.encoding import smart_unicode7 from util import ErrorList, ValidationError8 from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple9 5 import datetime 10 6 import re 11 7 import time 8 9 from django.utils.translation import ugettext 10 from django.utils.encoding import smart_unicode 11 12 from util import ErrorList, ValidationError 13 from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple 12 14 13 15 __all__ = ( django/branches/unicode/django/newforms/forms.py
r5241 r5279 3 3 """ 4 4 5 from django.utils.datastructures import SortedDict, MultiValueDict 5 import copy 6 7 from django.utils.datastructures import SortedDict 6 8 from django.utils.html import escape 7 9 from django.utils.encoding import StrAndUnicode, smart_unicode 10 8 11 from fields import Field 9 from widgets import TextInput, Textarea , HiddenInput, MultipleHiddenInput12 from widgets import TextInput, Textarea 10 13 from util import flatatt, ErrorDict, ErrorList, ValidationError 11 import copy12 14 13 15 __all__ = ('BaseForm', 'Form') django/branches/unicode/django/newforms/models.py
r5241 r5279 6 6 from django.utils.translation import ugettext 7 7 from django.utils.encoding import smart_unicode 8 8 9 from util import ValidationError 9 from forms import BaseForm, DeclarativeFieldsMetaclass,SortedDictFromList10 from forms import BaseForm, SortedDictFromList 10 11 from fields import Field, ChoiceField 11 12 from widgets import Select, SelectMultiple, MultipleHiddenInput 12 13 13 __all__ = ('save_instance', 'form_for_model', 'form_for_instance', 'form_for_fields', 14 'ModelChoiceField', 'ModelMultipleChoiceField') 14 __all__ = ( 15 'save_instance', 'form_for_model', 'form_for_instance', 'form_for_fields', 16 'ModelChoiceField', 'ModelMultipleChoiceField' 17 ) 15 18 16 19 def save_instance(form, instance, fields=None, fail_message='saved', commit=True): django/branches/unicode/django/newforms/util.py
r5223 r5279 1 from django.conf import settings2 1 from django.utils.html import escape 3 from django.utils.functional import Promise, lazy4 2 from django.utils.encoding import smart_unicode 5 3 django/branches/unicode/django/newforms/widgets.py
r5229 r5279 3 3 """ 4 4 5 __all__ = ( 6 'Widget', 'TextInput', 'PasswordInput', 'HiddenInput', 'MultipleHiddenInput', 7 'FileInput', 'Textarea', 'CheckboxInput', 8 'Select', 'NullBooleanSelect', 'SelectMultiple', 'RadioSelect', 'CheckboxSelectMultiple', 9 'MultiWidget', 'SplitDateTimeWidget', 10 ) 11 12 from util import flatatt 5 try: 6 set # Only available in Python 2.4+ 7 except NameError: 8 from sets import Set as set # Python 2.3 fallback 9 from itertools import chain 10 13 11 from django.utils.datastructures import MultiValueDict 14 12 from django.utils.html import escape 15 13 from django.utils.translation import ugettext 16 14 from django.utils.encoding import StrAndUnicode, smart_unicode 17 from itertools import chain 18 19 try: 20 set # Only available in Python 2.4+ 21 except NameError: 22 from sets import Set as set # Python 2.3 fallback 15 16 from util import flatatt 17 18 __all__ = ( 19 'Widget', 'TextInput', 'PasswordInput', 20 'HiddenInput', 'MultipleHiddenInput', 21 'FileInput', 'Textarea', 'CheckboxInput', 22 'Select', 'NullBooleanSelect', 'SelectMultiple', 'RadioSelect', 23 'CheckboxSelectMultiple', 'MultiWidget', 'SplitDateTimeWidget', 24 ) 23 25 24 26 class Widget(object): django/branches/unicode/docs/contributing.txt
r5185 r5279 280 280 for details. 281 281 282 * In Django template code, put one (and only one) space between the curly283 brackets and the tag contents.284 285 Do this::286 287 {{ foo }}288 289 Don't do this::290 291 {{foo}}292 293 * In Django views, the first parameter in a view function should be called294 ``request``.295 296 Do this::297 298 def my_view(request, foo):299 # ...300 301 Don't do this::302 303 def my_view(req, foo):304 # ...305 306 282 * Please don't put your name in the code you contribute. Our policy is to 307 283 keep contributors' names in the ``AUTHORS`` file distributed with Django … … 309 285 change to the ``AUTHORS`` file in your patch if you make more than a 310 286 single trivial change. 287 288 Template style 289 -------------- 290 291 * In Django template code, put one (and only one) space between the curly 292 brackets and the tag contents. 293 294 Do this:: 295 296 {{ foo }} 297 298 Don't do this:: 299 300 {{foo}} 301 302 View style 303 ---------- 304 305 * In Django views, the first parameter in a view function should be called 306 ``request``. 307 308 Do this:: 309 310 def my_view(request, foo): 311 # ... 312 313 Don't do this:: 314 315 def my_view(req, foo): 316 # ... 317 318 Model style 319 ----------- 320 321 * Field names should be all lowercase, using underscores instead of 322 camelCase. 323 324 Do this:: 325 326 class Person(models.Model): 327 first_name = models.CharField(maxlength=20) 328 last_name = models.CharField(maxlength=40) 329 330 Don't do this:: 331 332 class Person(models.Model): 333 FirstName = models.CharField(maxlength=20) 334 Last_Name = models.CharField(maxlength=40) 335 336 * The ``class Meta`` should appear *after* the fields are defined, with 337 a single blank line separating the fields and the class definition. 338 339 Do this:: 340 341 class Person(models.Model): 342 first_name = models.CharField(maxlength=20) 343 last_name = models.CharField(maxlength=40) 344 345 class Meta: 346 verbose_name_plural = 'people' 347 348 Don't do this:: 349 350 class Person(models.Model): 351 first_name = models.CharField(maxlength=20) 352 last_name = models.CharField(maxlength=40) 353 class Meta: 354 verbose_name_plural = 'people' 355 356 Don't do this, either:: 357 358 class Person(models.Model): 359 class Meta: 360 verbose_name_plural = 'people' 361 362 first_name = models.CharField(maxlength=20) 363 last_name = models.CharField(maxlength=40) 364 365 * The order of model inner classes and standard methods should be as 366 follows (noting that these are not all required): 367 368 * All database fields 369 * ``class Meta`` 370 * ``class Admin`` 371 * ``def __str__()`` 372 * ``def save()`` 373 * ``def get_absolute_url()`` 374 * Any custom methods 375 376 * If ``choices`` is defined for a given model field, define the choices as 377 a tuple of tuples, with an all-uppercase name, either near the top of the 378 model module or just above the model class. Example:: 379 380 GENDER_CHOICES = ( 381 ('M', 'Male'), 382 ('F', 'Female'), 383 ) 311 384 312 385 Committing code django/branches/unicode/docs/db-api.txt
r5126 r5279 144 144 145 145 * If the object's primary key attribute is set to a value that evaluates to 146 ``True`` (i.e., a value other than ``None`` or the empty string), Django 147 executes a ``SELECT`` query to determine whether a record with the given 146 ``True`` (i.e., a value other than ``None`` or the empty string), Django 147 executes a ``SELECT`` query to determine whether a record with the given 148 148 primary key already exists. 149 149 * If the record with the given primary key does already exist, Django … … 526 526 >>> Entry.objects.filter(headline__contains='Lennon').dates('pub_date', 'day') 527 527 [datetime.datetime(2005, 3, 20)] 528 528 529 529 ``none()`` 530 530 ~~~~~~~~~~ … … 532 532 **New in Django development version** 533 533 534 Returns an ``EmptyQuerySet`` -- a ``QuerySet`` that always evaluates to 534 Returns an ``EmptyQuerySet`` -- a ``QuerySet`` that always evaluates to 535 535 an empty list. This can be used in cases where you know that you should 536 536 return an empty result set and your caller is expecting a ``QuerySet`` … … 538 538 539 539 Examples:: 540 540 541 541 >>> Entry.objects.none() 542 542 [] … … 611 611 612 612 The ``depth`` argument is new in the Django development version. 613 613 614 614 ``extra(select=None, where=None, params=None, tables=None)`` 615 615 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 1137 1137 ~~~~~~ 1138 1138 1139 Takes either ``True`` or ``False``, which correspond to SQL queries of 1139 Takes either ``True`` or ``False``, which correspond to SQL queries of 1140 1140 ``IS NULL`` and ``IS NOT NULL``, respectively. 1141 1141 … … 1150 1150 .. admonition:: ``__isnull=True`` vs ``__exact=None`` 1151 1151 1152 There is an important difference between ``__isnull=True`` and 1152 There is an important difference between ``__isnull=True`` and 1153 1153 ``__exact=None``. ``__exact=None`` will *always* return an empty result 1154 set, because SQL requires that no value is equal to ``NULL``. 1155 ``__isnull`` determines if the field is currently holding the value 1154 set, because SQL requires that no value is equal to ``NULL``. 1155 ``__isnull`` determines if the field is currently holding the value 1156 1156 of ``NULL`` without performing a comparison. 1157 1157 … … 1182 1182 1183 1183 For convenience, Django provides a ``pk`` lookup type, which stands for 1184 "primary_key". 1184 "primary_key". 1185 1185 1186 1186 In the example ``Blog`` model, the primary key is the ``id`` field, so these … … 1191 1191 Blog.objects.get(pk=14) # pk implies id__exact 1192 1192 1193 The use of ``pk`` isn't limited to ``__exact`` queries -- any query term 1193 The use of ``pk`` isn't limited to ``__exact`` queries -- any query term 1194 1194 can be combined with ``pk`` to perform a query on the primary key of a model:: 1195 1195 … … 1197 1197 Blog.objects.filter(pk__in=[1,4,7]) 1198 1198 # Get all blog entries with id > 14 1199 Blog.objects.filter(pk__gt=14) 1200 1199 Blog.objects.filter(pk__gt=14) 1200 1201 1201 ``pk`` lookups also work across joins. For example, these three statements are 1202 1202 equivalent:: … … 1755 1755 1756 1756 One common idiom to use ``get()`` and raise ``Http404`` if the 1757 object doesn't exist. This idiom is captured by ``get_object_or_404()``. 1758 This function takes a Django model as its first argument and an 1759 arbitrary number of keyword arguments, which it passes to the manager's 1757 object doesn't exist. This idiom is captured by ``get_object_or_404()``. 1758 This function takes a Django model as its first argument and an 1759 arbitrary number of keyword arguments, which it passes to the manager's 1760 1760 ``get()`` function. It raises ``Http404`` if the object doesn't 1761 exist. For example:: 1762 1761 exist. For example:: 1762 1763 1763 # Get the Entry with a primary key of 3 1764 1764 e = get_object_or_404(Entry, pk=3) 1765 1765 1766 When you provide a model to this shortcut function, the default manager 1767 is used to execute the underlying ``get()`` query. If you don't want to 1768 use the default manager, or you want to search a list of related objects,1769 you can provide ``get_object_or_404()`` with a manager object , instead.1766 When you provide a model to this shortcut function, the default manager 1767 is used to execute the underlying ``get()`` query. If you don't want to 1768 use the default manager, or if you want to search a list of related objects, 1769 you can provide ``get_object_or_404()`` with a manager object instead. 1770 1770 For example:: 1771 1771 … … 1780 1780 ----------------- 1781 1781 1782 ``get_list_or_404`` behaves the same wa s as ``get_object_or_404()``1783 -- except th e it uses using ``filter()`` instead of ``get()``. It raises1782 ``get_list_or_404`` behaves the same way as ``get_object_or_404()`` 1783 -- except that it uses ``filter()`` instead of ``get()``. It raises 1784 1784 ``Http404`` if the list is empty. 1785 1785 django/branches/unicode/docs/model-api.txt
r5185 r5279 1760 1760 <a href="{{ object.get_absolute_url }}">{{ object.name }}</a> 1761 1761 1762 .. note:: 1763 The string you return from ``get_absolute_url()`` must be use only ASCII 1764 characters (required by the URI spec, `RFC 2396`_) that has been 1765 URL-encoded, if necessary. Code and templates using ``get_absolute_url()`` 1766 should be able to use the result directly without needing to do any 1767 further processing. 1768 1769 .. _RFC 2396: http://www.ietf.org/rfc/rfc2396.txt 1770 1762 1771 The ``permalink`` decorator 1763 1772 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ django/branches/unicode/docs/syndication_feeds.txt
r5151 r5279 147 147 passing it a single parameter, ``item``, which is the object itself. 148 148 Both ``get_absolute_url()`` and ``item_link()`` should return the item's 149 URL as a normal Python string. 149 URL as a normal Python string. As with ``get_absolute_url()``, the 150 result of ``item_link()`` will be included directly in the URL, so you 151 are responsible for doing all necessary URL quoting and conversion to 152 ASCII inside the method itself. 150 153 151 154 * For the LatestEntries example above, we could have very simple feed templates: django/branches/unicode/extras/django_bash_completion
r4677 r5279 43 43 44 44 # Standalone options 45 opts="--help --settings --pythonpath -- version"45 opts="--help --settings --pythonpath --noinput --noreload --format --indent --verbosity --adminmedia --version" 46 46 # Actions 47 47 actions="adminindex createcachetable dbshell diffsettings \ 48 inspectdb installreset runfcgi runserver \49 shell sql sqlall sqlclear sql indexes sqlinitialdata\48 dumpdata flush inspectdb loaddata reset runfcgi runserver \ 49 shell sql sqlall sqlclear sqlcustom sqlflush sqlindexes \ 50 50 sqlreset sqlsequencereset startapp startproject \ 51 syncdb validate"51 syncdb test validate" 52 52 # Action's options 53 53 action_shell_opts="--plain" … … 85 85 else 86 86 case ${prev} in 87 adminindex|install|reset| \ 88 sql|sqlall|sqlclear|sqlindexes| \ 89 sqlinitialdata|sqlreset|sqlsequencereset) 90 # App completion 91 settings="" 92 # If settings.py in the PWD, use that 93 if [ -e settings.py ] ; then 94 settings="$PWD/settings.py" 95 else 96 # Use the ENV variable if it is set 97 if [ $DJANGO_SETTINGS_MODULE ] ; then 98 settings=$DJANGO_SETTINGS_MODULE 87 adminindex|dumpdata|reset| \ 88 sql|sqlall|sqlclear|sqlcustom|sqlindexes| \ 89 sqlreset|sqlsequencereset|test) 90 # App completion 91 settings="" 92 # If settings.py in the PWD, use that 93 if [ -e settings.py ] ; then 94 settings="$PWD/settings.py" 95 else 96 # Use the ENV variable if it is set 97 if [ $DJANGO_SETTINGS_MODULE ] ; then 98 settings=$DJANGO_SETTINGS_MODULE 99 fi 99 100 fi 100 fi 101 # Couldn't find settings so return nothing 102 if [ -z $settings ] ; then 103 COMPREPLY=() 104 # Otherwise inspect settings.py file 105 else 106 apps=`sed -n "/INSTALLED_APPS = (/,/)/p" $settings | \ 107 grep -v "django.contrib" | 108 sed -n "s/^[ ]*'\(.*\.\)*\(.*\)'.*$/\2 /pg" | \ 109 tr -d "\n"` 110 COMPREPLY=( $(compgen -W "${apps}" -- ${cur}) ) 111 fi 112 return 0 113 ;; 101 # Couldn't find settings so return nothing 102 if [ -z $settings ] ; then 103 COMPREPLY=() 104 # Otherwise inspect settings.py file 105 else 106 apps=`sed -n "/INSTALLED_APPS = (/,/)/p" $settings | \ 107 grep -v "django.contrib" | 108 sed -n "s/^[ ]*'\(.*\.\)*\(.*\)'.*$/\2 /pg" | \ 109 tr -d "\n"` 110 COMPREPLY=( $(compgen -W "${apps}" -- ${cur}) ) 111 fi 112 return 0 113 ;; 114 114 115 115 createcachetable|dbshell|diffsettings| \
