OPTIMIZE大django admin sql

时间:2016-01-09 15:05:47

标签: django

这是django管理项列表SQL,我只需要这三个字段:id \ title \ created not not all。 如何配置,谢谢!

SELECT `book_chapter`.`id`, `book_chapter`.`keywords_string`, 
`book_chapter`.`site_id`, `book_chapter`.`title`, `book_chapter`.`slug`,
`book_chapter`.`_meta_title`, `book_chapter`.`description`, `book_chapter`.`gen_description`,
`book_chapter`.`created`, `book_chapter`.`updated`, `book_chapter`.`status`, 
`book_chapter`.`publish_date`, `book_chapter`.`expiry_date`, `book_chapter`.`short_url`,
`book_chapter`.`in_sitemap`, `book_chapter`.`content`, `book_chapter`.`user_id`,
`book_chapter`.`book_id`, `book_chapter`.`volume_id`, `book_chapter`.`size`, `book_chapter`.`rank`, 
`book_books`.`id`, `book_books`.`keywords_string`, `book_books`.`site_id`, `book_books`.`title`, 
`book_books`.`slug`, `book_books`.`_meta_title`, `book_books`.`description`, `book_books`.`gen_description`,
`book_books`.`created`, `book_books`.`updated`, `book_books`.`status`, `book_books`.`publish_date`,
`book_books`.`expiry_date`, `book_books`.`short_url`, `book_books`.`in_sitemap`, `book_books`.`content`, 
`book_books`.`user_id`, `book_books`.`kind_id`, `book_books`.`country_id`, `book_books`.`area_id`,
`book_books`.`writer_id`, `book_books`.`clicks`, `book_books`.`downs`, `book_books`.`favs`, 
`book_books`.`length`, `book_books`.`push_title`, `book_books`.`push_slug`, `book_books`.`push_time`, 
`book_books`.`completed`, `book_books`.`mainrole`, `book_books`.`rolenum`, `book_books`.`image` 
FROM `book_chapter` INNER JOIN `book_books` ON ( `book_chapter`.`book_id` = `book_books`.`id` ) 
ORDER BY `book_chapter`.`id` DESC LIMIT 10

1 个答案:

答案 0 :(得分:0)

您的管理模型应该看起来像这样

class BookAdmin(AdminModel):
    list_display = ("title", "id", "created")