Code

Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#67 closed enhancement (fixed)

Make specifying 'human-readable' name optional.

Reported by: mmarshall at myrealbox dot com Owned by: adrian
Component: Core (Other) Version:
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I noticed that in the fields for the models in tutorial 1, three out of the four 'human-readable' names were identical to the 'machine-friendly' names.

Following the DRY principle, I think that the specifying the 'human-readable' name should be optional, defaulting to the machine-friendly name.

Here is a svn diff for a (trivial) implementation:

Index: django/core/meta.py
===================================================================
--- django/core/meta.py (revision 174)
+++ django/core/meta.py (working copy)
@@ -1564,13 +1564,13 @@
     # database level.
     empty_strings_allowed = True

-    def __init__(self, name, verbose_name, primary_key=False,
+    def __init__(self, name, verbose_name=None, primary_key=False,
         maxlength=None, unique=False, blank=False, null=False, db_index=None,
         core=False, rel=None, default=NOT_PROVIDED, editable=True,
         prepopulate_from=None, unique_for_date=None, unique_for_month=None,
         unique_for_year=None, validator_list=None, choices=None, radio_admin=None,
         help_text=''):
-        self.name, self.verbose_name = name, verbose_name
+        self.name, self.verbose_name = name, verbose_name or name
         self.primary_key = primary_key
         self.maxlength, self.unique = maxlength, unique
         self.blank, self.null = blank, null

Attachments (0)

Change History (1)

comment:1 Changed 9 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in [212]. Great suggestion.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.