darklow / django-suit

Modern theme for Django admin interface
http://djangosuit.com/
Other
2.32k stars 703 forks source link

Add '+' button missing for Foreign Key fields #288

Open onyekaa opened 10 years ago

onyekaa commented 10 years ago

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

cirotix commented 9 years ago

Hi Onyeka,

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

darklow commented 9 years ago

Which Django version?

cirotix commented 9 years ago

Django==1.7 django-suit==0.2.11

cirotix commented 9 years ago

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!

onyekaa commented 9 years ago

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.

SimonF89 commented 6 years ago

Found a solution which is working for me:

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