django-suit
django-suit copied to clipboard
Add '+' button missing for Foreign Key fields
Hi, so I've searched on this for two days and can't figure it out. None of my foreign key fields are showing the plus button that allows you to add a new item. Everything else works fine. When I disable suit, they show up fine on the default django theme.
class PersonInline(admin.TabularInline):
model = FilmRole
extra = 3
suit_classes = 'suit-tab suit-tab-cast'
class FilmForm(ModelForm):
class Meta:
model = Film
fields = ('poster','name', 'summary', 'language', 'running_time', 'rating', 'budget', 'sales', 'release_date', 'genre', 'state', 'country',)
widgets = {
'genre' : CheckboxSelectMultiple(),
'running_time' : EnclosedInput(append='minutes'),
'budget' : EnclosedInput(prepend='₦'),
'sales' : EnclosedInput(prepend='₦'),
'country': LinkedSelect,
}
class FilmAdmin(AdminImageMixin, admin.ModelAdmin):
form = FilmForm
list_display = ('name', 'film_thumbnail', 'release_date', )
inlines = (PersonInline,)
fieldsets = [
(None, {
'classes': ('suit-tab', 'suit-tab-general',),
'fields': ['poster','name', 'summary', 'language', 'running_time', 'rating', 'budget', 'sales', 'release_date', 'genre', 'state', 'country',]
}),
]
suit_form_tabs = (('general', 'General'), ('cast', 'Cast'))
I'm really stumped. I compared the code, and saw that it was loading the default format for the add button which is
<a href="/admin/people/person/add/?_to_field=id" class="add-another" id="add_id_filmrole_set-0-person" title="Add Another"></a>
But looking at the demo, it's supposed to be loading this
<a href="/admin/examples/continent/add/" class="add-another" id="add_id_continent" onclick="return showAddAnotherPopup(this);"><img src="/static/admin/img/icon_addlink.gif" width="10" height="10" alt="Add Another"></a>
Any idea where I'm going wrong? Thanks
Hi Onyeka,
I have the same problem. Did you find the bug? Otherwise I am going to investigate.
Which Django version?
Django==1.7 django-suit==0.2.11
I have found the bug, which is on my side.
I had tried Grappelli before switching to django-suit and the action.js was cached by my browser.
I guess that the OP was probably having the same problem so this issue could be closed.
Thank you for the quick reply!
Django 1.8
Not the same thing, unfortunately. I hadn't tried any other theme but django-suit. Issue still persists. This seems to only be the case on the dev server though. I set it up online and the buttons are showing fine. I just did a check and the django I have online is 1.7.
Found a solution which is working for me:
https://stackoverflow.com/questions/18602563/django-modelchoicefield-has-no-plus-button