From df66763406cc76e8d0c65b3a857c891c21c25f49 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Tue, 19 Jul 2005 17:20:37 +0000 Subject: 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 --- docs/tutorial01.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'docs/tutorial01.txt') 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``. -- cgit v1.3