3

I'm using Django 2.0.9 and I'm creating a simple TabularInline ModelAdmin, as follows:

class AnswerInline(admin.TabularInline):
    model = Answer

This is then used in a ModelAdmin object, like so: inlines = [AnswerInline]. The ModelAdmin is registered with the admin site.

Everything works as expected, except that I do not see the ability to add further inline models. Here's what I mean:

enter image description here

I've seen other inlines where there is such a button, which would dynamically add more fields that I can populate.

I've tried overriding things on the TabularInline, like setting has_add_permission to return true and setting max_num to 1000, but I still cannot get the button to show up.

Would appreciate some outside input here.

Thanks!

John
  • 143
  • 1
  • 11
  • did you check defining `extra = 1` in the class ? – Bijoy Jun 27 '18 at 03:37
  • @Bijoy I did, that does not change things unfortunately – John Jun 27 '18 at 04:04
  • 1
    Try the solution posted [here](https://stackoverflow.com/questions/26310368/why-has-the-add-another-button-disappeared-from-my-django-inlines-when-upgradi) – Bijoy Jun 27 '18 at 05:25
  • @Bijoy I re-ran `collectstatic` and sure enough, the add-option is back. Thank you! Mind writing this as an answer - I will accept it as correct, so you get the credit :) – John Jun 27 '18 at 23:24
  • 1
    thanks man, appreciate that, but that answer helped you, you should upvote that, mine was just a reference. Cant take credit for that ;-) – Bijoy Jun 28 '18 at 03:12
  • @Bijoy I just want to make sure that the question has an accepted answer, so others know that the solution worked. Plus the other question doesn't have an accepted answer. I ended up answering it myself and accepting it. Thanks for your help! – John Jun 30 '18 at 04:08

1 Answers1

2

The solution was to re-run collectstatic. Once I did that, the problem was solved.

This was previously answered in this question, but it was not accepted as correct. I'm writing it here so I can accept this answer so others know that it worked.

Thanks to @bijoy for pointing me to it in the comments.

John
  • 143
  • 1
  • 11