Author: kmtracey
Date: 2009-12-13 09:19:21 -0600 (Sun, 13 Dec 2009)
New Revision: 11842
Modified:
django/branches/releases/1.1.X/
django/branches/releases/1.1.X/docs/howto/custom-model-fields.txt
Log:
[1.1.X] Apply doc addition that somehow was left out of r11834. Refs #7977.
r11841 from trunk.
Property changes on: django/branches/releases/1.1.X
___________________________________________________________________
Name: svnmerge-integrated
-
/django/trunk:1-11500,11523,11527-11528,11531-11552,11554,11577,11579-11581,11588-11589,11591-11592,11596-11599,11601-11617,11619-11626,11628-11635,11637-11638,11643-11644,11648-11653,11656,11670,11678,11681,11684,11686,11688,11691,11693,11695,11697,11699,11701,11703,11705,11707,11714,11719,11732,11734,11740,11748,11751,11753,11756,11760,11800,11808,11815,11817,11822,11826,11833,11835,11837,11839
+
/django/trunk:1-11500,11523,11527-11528,11531-11552,11554,11577,11579-11581,11588-11589,11591-11592,11596-11599,11601-11617,11619-11626,11628-11635,11637-11638,11643-11644,11648-11653,11656,11670,11678,11681,11684,11686,11688,11691,11693,11695,11697,11699,11701,11703,11705,11707,11714,11719,11732,11734,11740,11748,11751,11753,11756,11760,11800,11808,11815,11817,11822,11826,11833,11835,11837,11839,11841
Modified: django/branches/releases/1.1.X/docs/howto/custom-model-fields.txt
===================================================================
--- django/branches/releases/1.1.X/docs/howto/custom-model-fields.txt
2009-12-13 15:16:48 UTC (rev 11841)
+++ django/branches/releases/1.1.X/docs/howto/custom-model-fields.txt
2009-12-13 15:19:21 UTC (rev 11842)
@@ -39,6 +39,8 @@
something like this::
class Hand(object):
+ """A hand of cards (bridge style)"""
+
def __init__(self, north, east, south, west):
# Input parameters are lists of cards ('Ah', '9s', etc)
self.north = north
@@ -163,6 +165,8 @@
from django.db import models
class HandField(models.Field):
+ """A hand of cards (bridge style)"""
+
def __init__(self, *args, **kwargs):
kwargs['max_length'] = 104
super(HandField, self).__init__(*args, **kwargs)
@@ -244,6 +248,8 @@
For example::
class HandField(models.Field):
+ """A hand of cards (bridge style)"""
+
__metaclass__ = models.SubfieldBase
def __init__(self, *args, **kwargs):
@@ -252,6 +258,21 @@
This ensures that the :meth:`to_python` method, documented below, will always
be
called when the attribute is initialized.
+
+Documenting your Custom Field
+-----------------------------
+
+As always, you should document your field type, so users will know what it is.
+The best way to do this is to simply provide a docstring for it. This will
+automatically be picked up by ``django.contrib.admindocs``, if you have it
+installed, and the first line of it will show up as the field type in the
+documentation for any model that uses your field. In the above examples, it
+will show up as 'A hand of cards (bridge style)'. Note that if you provide a
+more verbose docstring, only the first line will show up in
+``django.contrib.admindocs``. The full docstring will, of course, still be
+available through ``pydoc`` or the interactive interpreter's ``help()``
+function.
+
Useful methods
--------------
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.