stephenmcd / grappelli-safe

Admin skin for Mezzanine
Other
25 stars 59 forks source link

Tabular inlines > filebrowser-safe #81

Closed ezawadzki closed 7 years ago

ezawadzki commented 8 years ago

Hello,

I'm trying to use FileBrowser-Safe into tabular inlines. The inline generated on page loading is ok : I can display FileBrowser window which makes me able to select a file. Without loading the page, if I continue to add a file in a second inline, I can display the FileBrowser window but NOT selecting a file.

Here is the link generated on the second inline which makes me able to show FileBrowser window : javascript:FileBrowser.show('id_images-__prefix__-file',%20'/admin/media-library/browse/?pop=1&dir=images&type=Image');

__prefix__should be replaced by the current item id.

It works for other sibling fields (input, textarea and select) on the second inlines.

Django==1.9.7 grappelli-safe==0.4.4 (branch dynamic_stacked) filebrowser-safe==0.4.5

ryneeverett commented 8 years ago

prefixshould be replaced by the current item id.

FYI, last time I dug into django's inline javascript I found that the __prefix__ elements serve as templates which get copied and rendered into extra inlines by javascript. This has been a source of confusion before when one thinks the __prefix__ is a server-side bug.

jerivas commented 8 years ago

My latest commit to the dynamic_stacked branch should fix this.

ryneeverett commented 7 years ago

@jerivas Were you able to reproduce this? I cannot with the following:

# models.py
from django.db import models
from mezzanine.core.fields import FileField

class PrimaryModel(models.Model):
    title = models.CharField(blank=True, max_length=200)

class SecondaryModel(models.Model):
    file = FileField()
    primary = models.ForeignKey(PrimaryModel)

# admin.py
from django.contrib import admin
from .models import PrimaryModel, SecondaryModel

class SecondaryAdmin(admin.TabularInline):
    model = SecondaryModel

class PrimaryAdmin(admin.ModelAdmin):
    inlines = [SecondaryAdmin]

admin.site.register(PrimaryModel, PrimaryAdmin)
jerivas commented 7 years ago

Try inheriting from Mezzanine's inline admin classes. I was able to reproduce it that way.

ryneeverett commented 7 years ago

Thanks, that did it.

ryneeverett commented 7 years ago

Pretty sure this was fixed by filebrowser#93.