django-better-admin-arrayfield icon indicating copy to clipboard operation
django-better-admin-arrayfield copied to clipboard

Not working in Inline

Open nitishxp opened this issue 5 years ago • 9 comments

  • Django better admin ArrayField version: Latest Version
  • Django version: 2.2.10
  • Python version: 3.7
  • Operating System: Ubuntu

Description

I was using an array field on normal modal but when I have made a model as an inline then I was not able to get an array field.

I have attached my demo repo in Question Model I am not able to add options and answers https://github.com/nitishxp/abidibo

What I Did

Attached demo repo link.   [https://github.com/nitishxp/abidibo](url)

nitishxp avatar Feb 28 '20 06:02 nitishxp

I also need this feature) @gradam

ghost avatar May 04 '20 15:05 ghost

Same problem. Button "Add another" is not working.

StBalashov avatar Nov 26 '20 16:11 StBalashov

I was able to get this working in production by manually placing django_better_admin_arrayfield.min.js and django_better_admin_arrayfield.min.css in static/js and static/cssin my project, respectively.

gchure avatar Dec 22 '20 19:12 gchure

EDIT: sorry, I see the issue is with respect to an inline admin view, not a regular one.

Still, I will leave this comment in case it helps others.


FWIW for anyone using a normal admin view (not inline), I added the field but forgot to do the following steps from the setup, and got a "Add another" button which didn't do anything when clicked.

from django_better_admin_arrayfield.admin.mixins import DynamicArrayMixin

In your admin class add DynamicArrayMixin: ...

class MyModelAdmin(admin.ModelAdmin, DynamicArrayMixin):

After doing this the button was able to add fields. I did not have to copy any js or css file manually, but I did have to run python manage.py collectstatic to get the css and js files into the right place.

sometimescasey avatar Feb 24 '21 21:02 sometimescasey

@nitishxp Did you manage to find a solution?

iremsha avatar Mar 05 '21 04:03 iremsha

I also need this

TimurKady avatar Jun 25 '21 09:06 TimurKady

Adding DynamicArrayMixin to the Inline admin class worked for me.

class AtlasProfileInline(admin.StackedInline, DynamicArrayMixin):
    model = Profile
    can_delete = False
    verbose_name_plural = 'profiles'

class UserAdmin(BaseUserAdmin):
    inlines = (AtlasProfileInline,)

image

StevenMonty avatar Nov 30 '21 19:11 StevenMonty

Also works in my case (Django 4.0, django-better-admin-arrayfield 1.4.2). I did experience a similar issue because in my Inline class I was overwriting the Meta.js attribute, so the library js was not loading.

pauldamian avatar Feb 28 '22 15:02 pauldamian