mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Replaced property() usage with decorator in several places.
This commit is contained in:
parent
ebdfd656b4
commit
a02b5848ae
11 changed files with 36 additions and 36 deletions
|
@ -751,10 +751,10 @@ For example, this model has a few custom methods::
|
|||
else:
|
||||
return "Post-boomer"
|
||||
|
||||
def _get_full_name(self):
|
||||
@property
|
||||
def full_name(self):
|
||||
"Returns the person's full name."
|
||||
return '%s %s' % (self.first_name, self.last_name)
|
||||
full_name = property(_get_full_name)
|
||||
|
||||
The last method in this example is a :term:`property`.
|
||||
|
||||
|
|
|
@ -188,10 +188,10 @@ For example, the static definition for our Calendar Widget could also
|
|||
be defined in a dynamic fashion::
|
||||
|
||||
class CalendarWidget(forms.TextInput):
|
||||
def _media(self):
|
||||
@property
|
||||
def media(self):
|
||||
return forms.Media(css={'all': ('pretty.css',)},
|
||||
js=('animations.js', 'actions.js'))
|
||||
media = property(_media)
|
||||
|
||||
See the section on `Media objects`_ for more details on how to construct
|
||||
return values for dynamic ``media`` properties.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue