Opened 13 years ago
Closed 11 years ago
#17308 closed Cleanup/optimization (fixed)
Use short description with properties in the admin
Reported by: | Pablo Martín | Owned by: | Wiktor |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If you use a property in a list_display (e.g.) the name of the column will be a "pretty name" of the name of the property.
But this property could use "short_description" as follow (See patch)
Attachments (1)
Change History (10)
by , 13 years ago
Attachment: | patch_r17159.diff added |
---|
comment:1 by , 13 years ago
Needs documentation: | set |
---|---|
Needs tests: | set |
Triage Stage: | Unreviewed → Accepted |
Type: | New feature → Cleanup/optimization |
comment:2 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 12 years ago
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'
comment:4 by , 12 years ago
Triage Stage: | Accepted → Design decision needed |
---|
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.
comment:5 by , 12 years ago
Triage Stage: | Design decision needed → Accepted |
---|
comment:7 by , 11 years ago
Needs documentation: | unset |
---|---|
Needs tests: | unset |
comment:8 by , 11 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:9 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
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.