diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-07-19 17:20:37 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-07-19 17:20:37 +0000 |
| commit | df66763406cc76e8d0c65b3a857c891c21c25f49 (patch) | |
| tree | 0e6e293d8da53eb26fe8ef59678e5750901c970e /docs/tutorial01.txt | |
| parent | e243d8287442a65d8c620f5c4f3033aa7d6bbd82 (diff) | |
Fixed #67 -- Human-readable name is now optional in model fields. If a second positional argument isn't given, Django will use the first argument, converting underscores to spaces. This change is fully backwards-compatible.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@212 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/tutorial01.txt')
| -rw-r--r-- | docs/tutorial01.txt | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/docs/tutorial01.txt b/docs/tutorial01.txt index d2ad8e36e7..39d77fafd2 100644 --- a/docs/tutorial01.txt +++ b/docs/tutorial01.txt @@ -137,15 +137,15 @@ Edit the ``polls/models/polls.py`` file so that it looks like this:: class Poll(meta.Model): fields = ( - meta.CharField('question', 'question', maxlength=200), + meta.CharField('question', maxlength=200), meta.DateTimeField('pub_date', 'date published'), ) class Choice(meta.Model): fields = ( meta.ForeignKey(Poll), - meta.CharField('choice', 'choice', maxlength=200), - meta.IntegerField('votes', 'votes'), + meta.CharField('choice', maxlength=200), + meta.IntegerField('votes'), ) The code is straightforward. Each model is represented by a class that @@ -160,8 +160,12 @@ The first argument to each ``Field`` call is the field's name, in machine-friendly format. You'll use this value in your Python code, and your database will use it as the column name. -The second argument is the field's human-readable name. That's used in a couple -of introspective parts of Django, and it doubles as documentation. +The second, optional, argument is the field's human-readable name. That's used +in a couple of introspective parts of Django, and it doubles as documentation. +If this field isn't provided, Django will use the machine-readable name. In +this example, we've only defined a human-readable name for ``Poll.pub_date``. +For all other fields in this model, the field's machine-readable name will +suffice as its human-readable name. Some ``meta.*Field`` classes have additional required elements. ``meta.CharField``, for example, requires that you give it a ``maxlength``. |
