--
Ticket URL: <https://code.djangoproject.com/ticket/17308>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_docs: => 1
* needs_better_patch: => 0
* type: New feature => Cleanup/optimization
* needs_tests: => 1
* stage: Unreviewed => Accepted
Comment:
This needs a quick simple test, and perhaps a bullet point in the docs
under the section on list_display - but otherwise looks like a good idea,
as you shouldn't be penalized for making use of your methods as
properties.
--
Ticket URL: <https://code.djangoproject.com/ticket/17308#comment:1>
* owner: nobody => viciu
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/17308#comment:2>
Comment (by viciu):
I've reviewed a patch and it works for the use case when property is not
set with @property decorator.
So this will work:
{{{
def test_label_for_property(self):
class MockModelAdmin(object):
def fget(self):
return "this if from property"
fget.short_description = 'property short description'
test_from_property = property(fget=fget)
self.assertEqual(
label_for_field("test_from_property", Article,
model_admin=MockModelAdmin),
'property short description'
)
}}}
but this will not:
{{{
def test_label_for_property_decorator(self):
class MockModelAdmin(object):
@property
def test_from_property(self):
return "this if from property"
test_from_property.short_description = 'property short
description'
}}}
throwing
AttributeError: 'property' object has no attribute 'short_description'
--
Ticket URL: <https://code.djangoproject.com/ticket/17308#comment:3>
* stage: Accepted => Design decision needed
Comment:
In my opinion this needs decision/discussion, because setting
short_description is limited to usage of property as a function, not as a
decorator.
This is better then nothing on the other hand.
I may however send a pull request (patch + tests) if this is ok.
--
Ticket URL: <https://code.djangoproject.com/ticket/17308#comment:4>
* stage: Design decision needed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/17308#comment:5>
Comment (by viciu):
Pull request here: https://github.com/django/django/pull/1104
--
Ticket URL: <https://code.djangoproject.com/ticket/17308#comment:6>
* needs_docs: 1 => 0
* needs_tests: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/17308#comment:7>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/17308#comment:8>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"cec9558fba1bc6401ea2ec6d71b816b4dfd31b28"]:
{{{
#!CommitTicketReference repository=""
revision="cec9558fba1bc6401ea2ec6d71b816b4dfd31b28"
Fixed #17308 -- Enabled the use of short_description on properties in the
admin.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/17308#comment:9>