django-suit icon indicating copy to clipboard operation
django-suit copied to clipboard

Add '+' button missing for Foreign Key fields

Open onyekaa opened this issue 10 years ago • 6 comments

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='&#8358'),
            'sales' : EnclosedInput(prepend='&#8358'),
            '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

onyekaa avatar Sep 17 '14 01:09 onyekaa

Hi Onyeka,

I have the same problem. Did you find the bug? Otherwise I am going to investigate.

cirotix avatar Sep 30 '14 11:09 cirotix

Which Django version?

darklow avatar Sep 30 '14 11:09 darklow

Django==1.7 django-suit==0.2.11

cirotix avatar Sep 30 '14 12:09 cirotix

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!

cirotix avatar Sep 30 '14 13:09 cirotix

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.

onyekaa avatar Sep 30 '14 14:09 onyekaa

Found a solution which is working for me:

https://stackoverflow.com/questions/18602563/django-modelchoicefield-has-no-plus-button

SimonF89 avatar Jul 03 '18 07:07 SimonF89