How do I require an inline in the Django Admin?

前端 未结 6 1564
旧巷少年郎
旧巷少年郎 2020-12-13 09:44

I have the following admin setup so that I can add/edit a user and their profile at the same time.

class ProfileInline(admin.StackedInline):
    \"\"\"
             


        
6条回答
  •  半阙折子戏
    2020-12-13 10:13

    As of Django 3+ this is as simple as you like:

    class EmployeeAddressMap(admin.StackedInline):
        model = EmployeeAddress
        min_num = 1
        max_num = 1
        can_delete = False #specified that this cannnot be removed
    

    Happy coding

提交回复
热议问题