Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要编写以下查询
SELECT id, name, ( CASE WHEN photo = '' THEN 'DEFAULT_PIC' ELSE photo END ) AS image FROM admin_category
ORM可以处理吗?
它可以在模型中完成。
class Category(models.Model): ... @property def image(self): return self.photo or u'DEFAULT_PIC' # usage category.image