diff options
author | Boulder Sprinters <boulder-sprinters@djangoproject.com> | 2007-05-17 15:14:09 +0000 |
---|---|---|
committer | Boulder Sprinters <boulder-sprinters@djangoproject.com> | 2007-05-17 15:14:09 +0000 |
commit | 310ae7eccc09e0a488a81f690876018ca39f34a8 (patch) | |
tree | b914fc67fb1dfb2a100087b14ea6cb26f6151a43 | |
parent | 74e29250427c7e6f901ffdbb721f69516ba2f3f0 (diff) | |
download | django-310ae7eccc09e0a488a81f690876018ca39f34a8.tar.gz |
boulder-oracle-sprint: Merged to [5274]
git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@5275 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r-- | django/newforms/extras/widgets.py | 3 | ||||
-rw-r--r-- | django/newforms/fields.py | 8 | ||||
-rw-r--r-- | django/newforms/forms.py | 8 | ||||
-rw-r--r-- | django/newforms/models.py | 9 | ||||
-rw-r--r-- | django/newforms/util.py | 2 | ||||
-rw-r--r-- | django/newforms/widgets.py | 26 | ||||
-rw-r--r-- | docs/contributing.txt | 83 |
7 files changed, 110 insertions, 29 deletions
diff --git a/django/newforms/extras/widgets.py b/django/newforms/extras/widgets.py index 1011934fb8..724dcd9b50 100644 --- a/django/newforms/extras/widgets.py +++ b/django/newforms/extras/widgets.py @@ -2,9 +2,10 @@ Extra HTML Widget classes """ +import datetime + from django.newforms.widgets import Widget, Select from django.utils.dates import MONTHS -import datetime __all__ = ('SelectDateWidget',) diff --git a/django/newforms/fields.py b/django/newforms/fields.py index 509c099e86..30c675c14a 100644 --- a/django/newforms/fields.py +++ b/django/newforms/fields.py @@ -2,13 +2,15 @@ Field classes """ +import datetime +import re +import time + from django.utils.translation import gettext from django.utils.encoding import smart_unicode + from util import ErrorList, ValidationError from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple -import datetime -import re -import time __all__ = ( 'Field', 'CharField', 'IntegerField', diff --git a/django/newforms/forms.py b/django/newforms/forms.py index 0923cd50ea..952f41a8c9 100644 --- a/django/newforms/forms.py +++ b/django/newforms/forms.py @@ -2,13 +2,15 @@ Form classes """ -from django.utils.datastructures import SortedDict, MultiValueDict +import copy + +from django.utils.datastructures import SortedDict from django.utils.html import escape from django.utils.encoding import StrAndUnicode + from fields import Field -from widgets import TextInput, Textarea, HiddenInput, MultipleHiddenInput +from widgets import TextInput, Textarea from util import flatatt, ErrorDict, ErrorList, ValidationError -import copy __all__ = ('BaseForm', 'Form') diff --git a/django/newforms/models.py b/django/newforms/models.py index 9d7d027031..1f783429be 100644 --- a/django/newforms/models.py +++ b/django/newforms/models.py @@ -4,13 +4,16 @@ and database field objects. """ from django.utils.translation import gettext + from util import ValidationError -from forms import BaseForm, DeclarativeFieldsMetaclass, SortedDictFromList +from forms import BaseForm, SortedDictFromList from fields import Field, ChoiceField from widgets import Select, SelectMultiple, MultipleHiddenInput -__all__ = ('save_instance', 'form_for_model', 'form_for_instance', 'form_for_fields', - 'ModelChoiceField', 'ModelMultipleChoiceField') +__all__ = ( + 'save_instance', 'form_for_model', 'form_for_instance', 'form_for_fields', + 'ModelChoiceField', 'ModelMultipleChoiceField' +) def save_instance(form, instance, fields=None, fail_message='saved', commit=True): """ diff --git a/django/newforms/util.py b/django/newforms/util.py index 5fc0223f5b..cc17ff4f7f 100644 --- a/django/newforms/util.py +++ b/django/newforms/util.py @@ -1,6 +1,4 @@ -from django.conf import settings from django.utils.html import escape -from django.utils.functional import Promise, lazy from django.utils.encoding import smart_unicode # Converts a dictionary to a single string with key="value", XML-style with diff --git a/django/newforms/widgets.py b/django/newforms/widgets.py index dd71ebc455..6ee3177a25 100644 --- a/django/newforms/widgets.py +++ b/django/newforms/widgets.py @@ -2,24 +2,26 @@ HTML Widget classes """ -__all__ = ( - 'Widget', 'TextInput', 'PasswordInput', 'HiddenInput', 'MultipleHiddenInput', - 'FileInput', 'Textarea', 'CheckboxInput', - 'Select', 'NullBooleanSelect', 'SelectMultiple', 'RadioSelect', 'CheckboxSelectMultiple', - 'MultiWidget', 'SplitDateTimeWidget', -) +try: + set # Only available in Python 2.4+ +except NameError: + from sets import Set as set # Python 2.3 fallback +from itertools import chain -from util import flatatt from django.utils.datastructures import MultiValueDict from django.utils.html import escape from django.utils.translation import gettext from django.utils.encoding import StrAndUnicode, smart_unicode -from itertools import chain -try: - set # Only available in Python 2.4+ -except NameError: - from sets import Set as set # Python 2.3 fallback +from util import flatatt + +__all__ = ( + 'Widget', 'TextInput', 'PasswordInput', + 'HiddenInput', 'MultipleHiddenInput', + 'FileInput', 'Textarea', 'CheckboxInput', + 'Select', 'NullBooleanSelect', 'SelectMultiple', 'RadioSelect', + 'CheckboxSelectMultiple', 'MultiWidget', 'SplitDateTimeWidget', +) class Widget(object): is_hidden = False # Determines whether this corresponds to an <input type="hidden">. diff --git a/docs/contributing.txt b/docs/contributing.txt index d05c166b37..31409f27bd 100644 --- a/docs/contributing.txt +++ b/docs/contributing.txt @@ -279,6 +279,15 @@ Please follow these coding standards when writing code for inclusion in Django: * Mark all strings for internationalization; see the `i18n documentation`_ for details. + * Please don't put your name in the code you contribute. Our policy is to + keep contributors' names in the ``AUTHORS`` file distributed with Django + -- not scattered throughout the codebase itself. Feel free to include a + change to the ``AUTHORS`` file in your patch if you make more than a + single trivial change. + +Template style +-------------- + * In Django template code, put one (and only one) space between the curly brackets and the tag contents. @@ -290,6 +299,9 @@ Please follow these coding standards when writing code for inclusion in Django: {{foo}} +View style +---------- + * In Django views, the first parameter in a view function should be called ``request``. @@ -303,11 +315,72 @@ Please follow these coding standards when writing code for inclusion in Django: def my_view(req, foo): # ... - * Please don't put your name in the code you contribute. Our policy is to - keep contributors' names in the ``AUTHORS`` file distributed with Django - -- not scattered throughout the codebase itself. Feel free to include a - change to the ``AUTHORS`` file in your patch if you make more than a - single trivial change. +Model style +----------- + + * Field names should be all lowercase, using underscores instead of + camelCase. + + Do this:: + + class Person(models.Model): + first_name = models.CharField(maxlength=20) + last_name = models.CharField(maxlength=40) + + Don't do this:: + + class Person(models.Model): + FirstName = models.CharField(maxlength=20) + Last_Name = models.CharField(maxlength=40) + + * The ``class Meta`` should appear *after* the fields are defined, with + a single blank line separating the fields and the class definition. + + Do this:: + + class Person(models.Model): + first_name = models.CharField(maxlength=20) + last_name = models.CharField(maxlength=40) + + class Meta: + verbose_name_plural = 'people' + + Don't do this:: + + class Person(models.Model): + first_name = models.CharField(maxlength=20) + last_name = models.CharField(maxlength=40) + class Meta: + verbose_name_plural = 'people' + + Don't do this, either:: + + class Person(models.Model): + class Meta: + verbose_name_plural = 'people' + + first_name = models.CharField(maxlength=20) + last_name = models.CharField(maxlength=40) + + * The order of model inner classes and standard methods should be as + follows (noting that these are not all required): + + * All database fields + * ``class Meta`` + * ``class Admin`` + * ``def __str__()`` + * ``def save()`` + * ``def get_absolute_url()`` + * Any custom methods + + * If ``choices`` is defined for a given model field, define the choices as + a tuple of tuples, with an all-uppercase name, either near the top of the + model module or just above the model class. Example:: + + GENDER_CHOICES = ( + ('M', 'Male'), + ('F', 'Female'), + ) Committing code =============== |