简体   繁体   中英

Nested display in django admin (multipe foreign keys)

Let's say I have 3 models, a company, its divisions, and the divisions' employees. Divisions have a foreign key to companies and employees have a foreign key to divisions. Is there a way to make it work so that the list display in the django admin for companies does something like:

General Electric
    Finance
            Tom Brown
            Bill Black
            John Green
    Technology
            Deer Rabbit
    Marketing
Target
    ...

Yes totally, to be able to do that you will have to customize your admin views, here are the docs: http://www.djangobook.com/en/1.0/chapter17/

There is very similar example in the docs so it should be easy to follow :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM