Opened 7 years ago
Closed 7 years ago
#29385 closed Cleanup/optimization (fixed)
Make ModelDetailView show model properties
Reported by: | Bostjan Kaluza | Owned by: | humbertotm |
---|---|---|---|
Component: | contrib.admindocs | Version: | 2.0 |
Severity: | Normal | Keywords: | |
Cc: | Nat S Dunn | 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
Model properties (like one below) do not show in the admin documentation:
class MyModel(models.Model): name = models.CharField(max_length=200) public = models.BooleanField(default=False) date_approved = models.DateTimeField(null=True, blank=True) @property def status(self): """ returns the status of object """ if self.date_approved and self.public: return "Public" elif self.public: return "Pending Approval" else: return "Private"
Change History (12)
comment:1 by , 7 years ago
comment:3 by , 7 years ago
Has patch: | set |
---|---|
Patch needs improvement: | set |
Summary: | Admindocs doesn't show model properties → Make ModelDetailView show model properties |
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → Cleanup/optimization |
A test and documentation update are also required.
comment:4 by , 7 years ago
Cc: | added |
---|
comment:5 by , 7 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
I'd be glad to work on the required test and documentation.
comment:6 by , 7 years ago
Pull request: https://github.com/django/django/pull/10004
Building on the fix provided by PR #9929, a unit test for the enhancement has been added. Additional documentation has not been added as the fix seems to fall within what is covered by The Django admin documentation generator. I will be glad to continue documenting with a bit of orientation.
Let me know if you have any comments regarding the unit test.
follow-up: 8 comment:7 by , 7 years ago
For the docs, something like with all the fields and methods available on it
-> with all the fields, properties and methods available on it
, with a versionchanged
section stating that showing model properties has been added.
follow-up: 9 comment:8 by , 7 years ago
Replying to Claude Paroz:
For the docs, something like
with all the fields and methods available on it
->with all the fields, properties and methods available on it
, with aversionchanged
section stating that showing model properties has been added.
Great! I'm on it.
Thanks!
comment:9 by , 7 years ago
Added documentation to PR. Let me know what you think, and how this can be improved.
Thanks!
comment:10 by , 7 years ago
Patch needs improvement: | unset |
---|
comment:11 by , 7 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
It seem easy to fix. In file
django/contrib/admindocs/views.py
methodModelDetailView.get_context_data
gathers model methods, but skips the properties as they are not methods. So we need to (1) add properties to the condition and (2) append the property to the list of fields.