summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorBoulder Sprinters <boulder-sprinters@djangoproject.com>2007-05-17 15:14:09 +0000
committerBoulder Sprinters <boulder-sprinters@djangoproject.com>2007-05-17 15:14:09 +0000
commit310ae7eccc09e0a488a81f690876018ca39f34a8 (patch)
treeb914fc67fb1dfb2a100087b14ea6cb26f6151a43 /docs
parent74e29250427c7e6f901ffdbb721f69516ba2f3f0 (diff)
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
Diffstat (limited to 'docs')
-rw-r--r--docs/contributing.txt83
1 files changed, 78 insertions, 5 deletions
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
===============