DeAdmin | 一个用VueJSAdminLTE实现的后台管理系统
kandi X-RAY | DeAdmin Summary
kandi X-RAY | DeAdmin Summary
不再维护!!!版本过老 莫要fork 目前本人在用的版本由于是公司内部的 不方便开源~.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of DeAdmin
DeAdmin Key Features
DeAdmin Examples and Code Snippets
Community Discussions
Trending Discussions on DeAdmin
QUESTION
In my Django model
, I defined a @property
which worked nicely and the property can be shown in the admin list_display
without any problems.
I need this property not only in admin but in my code logic in other places as well, so it makes sense to have it as property for my model.
Now I wanted to make the column of this property sortable, and with help of the Django documentation of the When object, this StackOverflow question for the F()-calculation and this link for the sorting I managed to build the working solution shown below.
The reason for posing a question here is: In fact, I implemented my logic twice, once in python and once in form of an expression, which is against the design rule of implementing the same logic only once. So I wanted to ask whether I missed a better solution to my problem. Any ideas are appreciated.
This is the model (identifyers modified):
...ANSWER
Answered 2019-Oct-16 at 18:08Although I think your solution is very good (or even better), the another approach can be to extract admin query to the model manager:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install DeAdmin
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page