3

I have a foreign key in model and I am making inline in admin side. I passed extra=0 to display only one form and its working but I am getting Add another model in admin.

I dont want to display Add another model in admin just one form only.

How can I do that . How can I remove Add another option from admin

varad
  • 7,309
  • 20
  • 60
  • 112

2 Answers2

5

Instead of using ForeignKey, use OneToOneField and it will display just one item without the add another link.

karthikr
  • 97,368
  • 26
  • 197
  • 188
Daian Gan
  • 81
  • 1
  • 3
1

if you want only 1 inline can be added. You can use max_num option.

class MyModelInline(admin.TabularInline):
    model = MyModel
    extra = 0
    max_num = 1
Doni
  • 46
  • 2