Code Monkey home page Code Monkey logo

django-better-admin-arrayfield's Introduction

Hello, I'm Jakub

I'm a fullstack web developer

The code is just a tool, but still, you have to know how to use it.

I help people (and sometimes myself) make ideas come true. I've been doing it for over half a decade now! Technologies such as Python, React or AWS were very helpful along the way.

I am passionate about entrepreneurship, startups, new technologies and sharing knowledge. I am a mentor for several aspiring programmers and ex-mentor for some that have become mentors themselves.

Let's connect and chat! Open to anything under the sun.

django-better-admin-arrayfield's People

Contributors

davitovmasyan avatar dependabot-preview[bot] avatar dependabot[bot] avatar dmartin avatar gradam avatar javiermatos avatar jrobichaud avatar liqiongyu avatar marcelovicentegc avatar martincura avatar mondeja avatar paterit avatar sergei-maertens avatar sixthgear avatar sourcery-ai-bot avatar swojak-a avatar usmandap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

django-better-admin-arrayfield's Issues

SyntaxError: invalid syntax,

  • Django better admin ArrayField version: 1.0.2 release
  • Django version: 1.11.17
  • Python version: 2.7
  • Operating System: Windows 10

Description

Below are the steps I took till now:

  1. pip install django-better-admin-arrayfield
  2. included 'django_better_admin_arrayfield.apps.DjangoBetterAdminArrayfieldConfig', as the last field under 'installed apps' in settings
  3. replaced old arrayfield import in models.py with 'from django_better_admin_arrayfield.models.fields import ArrayField'
  4. In admin.py, imported DynamicArrayMixin as below:
    from django_better_admin_arrayfield.admin.mixins import DynamicArrayMixin
  5. Created ModelAdmin in admin.py as:
    class SpotModelAdmin(admin.ModelAdmin, DynamicArrayMixin):
    pass
  6. Registered model with its ModelAdmin as below:
    admin.site.register(Spot, SpotModelAdmin) #(Spot is the name of model in which arrayfield is used.)
  7. When running makemigrations, I am getting syntax error.
    Check following traceback after running command makemigrations.
>> python manage.py makemigrations
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "D:\Program Files (x86)\Python\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "D:\Program Files (x86)\Python\lib\site-packages\django\core\management\__init__.py", line 338, in execute
    django.setup()
  File "D:\Program Files (x86)\Python\lib\site-packages\django\__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\Program Files (x86)\Python\lib\site-packages\django\apps\registry.py", line 108, in populate
    app_config.import_models()
  File "D:\Program Files (x86)\Python\lib\site-packages\django\apps\config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "D:\Program Files (x86)\Python\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File "E:\SHRIKANT\django practice\myproject\travelsite\mockup3\spot\models.py", line 5, in <module>
    from django_better_admin_arrayfield.models.fields import ArrayField
  File "D:\Program Files (x86)\Python\lib\site-packages\django_better_admin_arrayfield\models\fields.py", line 8
    return super().formfield(**{"form_class": DynamicArrayField, **kwargs})
                                                                  ^
SyntaxError: invalid syntax

Can't get 'DynamicArrayMixin' to import.

  • Django better admin ArrayField version: 1.0.2
  • Django version: 2.1.7
  • Python version: 3.7
  • Operating System: docker python:3.7-alpine

Description

Trying to use your plug in to make my django admin arrayfields a bit more usable. I have a model where I'm using in conjunction with summernote. Maybe it's because I'm thick like crazy, but I can't get DynamicArrayMixin to work properly with my admin class. When I try to run my the django app using docker-compose all I get the following error:

class ListingAdmin(SummernoteModelAdmin, DynamicArrayMixin):
NameError: name 'DynamicArrayMixin' is not defined

I tried to define it any way I could, but I just couldn't get it to go.

Thanks for all your help.

The custom form field does not respect the model field default

  • Django better admin ArrayField version: 1.0.4
  • Django version: 2.2.4
  • Python version: 3.7.5
  • Operating System: Linux (5.3.11)

Description

The form field validation incorrectly transforms falsy values to None (and thus null in the database), while the model has been correctly specified with a default of empty list (default=list).

Even though the field is not required, this now produces server errors because the field is trying to insert null values in a not-nullable column.

The suspected offending code is in django_better_admin_arrayfield.forms.DynamicArrayField.clean:

    def clean(self, value):
        cleaned_data = []
        errors = []
        value = list(filter(None, value))
        if not value:
            cleaned_data = None  # this should probably call the `model_field.default`
        for index, item in enumerate(value):
            print(index, item)
            try:
                cleaned_data.append(self.base_field.clean(item))
            except forms.ValidationError as error:
                errors.append(
                    prefix_validation_error(
                        error, self.error_messages["item_invalid"], code="item_invalid", params={"nth": index}
                    )
                )
        if errors:
            raise forms.ValidationError(list(chain.from_iterable(errors)))
        if not cleaned_data and self.required:
            raise forms.ValidationError(self.error_messages["required"])
        return cleaned_data

What I Did

# model field
    trefwoorden = ArrayField(
        models.CharField(_("trefwoord"), max_length=30),
        blank=True,
        default=list,
        help_text=_(
            "Een trefwoord waarmee ZAAKen van het ZAAKTYPE kunnen worden gekarakteriseerd."
        ),
        db_index=True,
    )

Leave field empty in the admin + submit the form

Crash:

Environment:


Request Method: POST
Request URL: http://localhost:8000/admin/catalogi/zaaktype/8/change/?_changelist_filters=catalogus%3D5

Django Version: 2.2.4
Python Version: 3.7.5
Installed Applications:
['django.contrib.contenttypes',
 'django.contrib.auth',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'ordered_model',
 'django_admin_index',
 'django.contrib.admin',
 'django.contrib.gis',
 'axes',
 'django_filters',
 'corsheaders',
 'vng_api_common',
 'vng_api_common.authorizations',
 'vng_api_common.audittrails',
 'vng_api_common.notifications',
 'drf_yasg',
 'rest_framework',
 'rest_framework_gis',
 'django_markup',
 'solo',
 'privates',
 'django_better_admin_arrayfield.apps.DjangoBetterAdminArrayfieldConfig',
 'django_loose_fk',
 'openzaak',
 'openzaak.accounts',
 'openzaak.utils',
 'openzaak.components.authorizations',
 'openzaak.components.zaken',
 'openzaak.components.besluiten',
 'openzaak.components.documenten',
 'openzaak.components.catalogi',
 'openzaak.selectielijst.apps.SelectielijstConfig',
 'debug_toolbar',
 'django_extensions']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'openzaak.utils.middleware.LogHeadersMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'openzaak.components.authorizations.middleware.AuthMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'vng_api_common.middleware.APIVersionHeaderMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware']



Traceback:

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/db/backends/utils.py" in _execute
  84.                 return self.cursor.execute(sql, params)

The above exception (null value in column "trefwoorden" violates not-null constraint
DETAIL:  Failing row contains (8, 2019-02-21, null, t, ede2fd28-32d2-46c9-8cde-b44bb055d3bc, 40, Aanvraag huwelijk behandelen, , intern, -, -, , extern, Indienen, Huwelijk, Behandelen, 5 days, null, f, f, null, null, f, , null, 2019-02-21, {https://pki.utrecht.nl/Loket/product/298304036ec988f0633d839dde..., https://referentielijsten-api.vng.cloud/api/v1/procestypen/39a17..., Huwelijk, , 5).
) was the direct cause of the following exception:

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
  115.                 response = self.process_exception_by_middleware(e, request)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
  113.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/contrib/admin/options.py" in wrapper
  606.                 return self.admin_site.admin_view(view)(*args, **kwargs)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/utils/decorators.py" in _wrapped_view
  142.                     response = view_func(request, *args, **kwargs)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/contrib/admin/sites.py" in inner
  223.             return view(request, *args, **kwargs)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/contrib/admin/options.py" in change_view
  1637.         return self.changeform_view(request, object_id, form_url, extra_context)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/utils/decorators.py" in _wrapper
  45.         return bound_method(*args, **kwargs)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/utils/decorators.py" in _wrapped_view
  142.                     response = view_func(request, *args, **kwargs)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/contrib/admin/options.py" in changeform_view
  1522.             return self._changeform_view(request, object_id, form_url, extra_context)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/contrib/admin/options.py" in _changeform_view
  1561.                 self.save_model(request, new_object, form, not add)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/contrib/admin/options.py" in save_model
  1088.         obj.save()

File "/home/bbt/code/zaken/open-zaak/src/openzaak/components/catalogi/models/zaaktype.py" in save
  382.         super().save(*args, **kwargs)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/db/models/base.py" in save
  741.                        force_update=force_update, update_fields=update_fields)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/db/models/base.py" in save_base
  779.                 force_update, using, update_fields,

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/db/models/base.py" in _save_table
  851.                                       forced_update)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/db/models/base.py" in _do_update
  900.         return filtered._update(values) > 0

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/db/models/query.py" in _update
  760.         return query.get_compiler(self.db).execute_sql(CURSOR)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  1429.         cursor = super().execute_sql(result_type)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  1100.             cursor.execute(sql, params)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/debug_toolbar/panels/sql/tracking.py" in execute
  192.         return self._record(self.cursor.execute, sql, params)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/debug_toolbar/panels/sql/tracking.py" in _record
  126.             return method(sql, params)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/db/backends/utils.py" in execute
  99.             return super().execute(sql, params)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/db/backends/utils.py" in execute
  67.         return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/db/backends/utils.py" in _execute_with_wrappers
  76.         return executor(sql, params, many, context)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/db/backends/utils.py" in _execute
  84.                 return self.cursor.execute(sql, params)

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/db/utils.py" in __exit__
  89.                 raise dj_exc_value.with_traceback(traceback) from exc_value

File "/home/bbt/.virtualenvs/open-zaak/lib/python3.7/site-packages/django/db/backends/utils.py" in _execute
  84.                 return self.cursor.execute(sql, params)

Exception Type: IntegrityError at /admin/catalogi/zaaktype/8/change/
Exception Value: null value in column "trefwoorden" violates not-null constraint
DETAIL:  Failing row contains (8, 2019-02-21, null, t, ede2fd28-32d2-46c9-8cde-b44bb055d3bc, 40, Aanvraag huwelijk behandelen, , intern, -, -, , extern, Indienen, Huwelijk, Behandelen, 5 days, null, f, f, null, null, f, , null, 2019-02-21, {https://pki.utrecht.nl/Loket/product/298304036ec988f0633d839dde..., https://referentielijsten-api.vng.cloud/api/v1/procestypen/39a17..., Huwelijk, , 5).

Admin saving None instead of empty array

  • Django better admin ArrayField version: 1.1.0
  • Django version: 2.2.12
  • Python version: 3.6
  • Operating System: Windows

When i remove all elements from array in Django admin, it's saving None instead of empty array.

Cannot use textarea as subwidget_form

  • Django better admin ArrayField version: 1.4.2
  • Django version: 3.2.13
  • Python version: 3.7.13
  • Operating System: Mac OS 12.3.1

Description

I want to pass a custom subwidget_form to DynamicArrayWidget. Specifically, I want to use forms.TextAreainstead of forms.TextInput:

class MyModelAdmin(...):
    ...
    form = modelform_factory(
        ...
        widgets =  {
            "my_field_name": DynamicArrayWidget(subwidget_form=forms.Textarea),
        }
     )

When I do this, clicking on the "Add another" button throws a JS error:

django_better_admin_arrayfield.min.js:1 Uncaught TypeError: Cannot read properties of null (reading 'getAttribute')
    at HTMLInputElement.<anonymous> (django_better_admin_arrayfield.min.js:1:474)
(anonymous) @ django_better_admin_arrayfield.min.js:1

...because of this line:
https://github.com/gradam/django-better-admin-arrayfield/blob/master/django_better_admin_arrayfield/static/js/django_better_admin_arrayfield.js#L29

...because the querySelector is specifically looking for an input (not a textarea).

Issue with django.db.models.JSONField

  • Django better admin ArrayField version: 1.4.2
  • Django version: 3.2
  • Python version: 3.7.3
  • Operating System: Windows 11

Description

I added django.db.models.JSONField as the base field. Now when adding JSON on admin panel with single quotes its shows Enter a valid JSON, so I added JSON with double quotes and it worked but on the same page it then returned the same json with single quotes, so now I'm unable to edit the previous json until and unless I convert everything to double quotes.

Initial JSON:
image

JSON after instance save:
image

When resaving without any changes:
image

ArrayFields show up as changed in history on save even when untouched

  • Django better admin ArrayField version: 1.4.2
  • Django version: 3.1.3
  • Python version: 3.9.1
  • Operating System: Various

Description

ArrayFields show up on a model instance's history as changed on save even when no change was made to the field. It occurs even when left blank. Is this the expected behaviour?

What I Did

Save on model admin page without altering ArrayField.

Add translations

Description

I tried to translate the "Add another" button within the Django administration. Unfortunately, it is not wrapped in a {% trans %} tag.

Improve template to make it look as the rest of Django Admin elements

You can make the UI similar to the one Django Admin already has. I am mainly talking about the "Add another" button and the delete icon you are using.

{% load static %}
{% load i18n %}

{% spaceless %}
<div class="related-widget-wrapper">
    <div class="dynamic-array-widget">
        <ul>
            {% for subwidget in widget.subwidgets %}
                <li class="array-item" {% if widget.is_none %}data-isNone="true" style="display: none"{% endif %}>
                    {% with widget=subwidget %}
                        {% include widget.template_name %}
                    {% endwith %}
                    <div class="remove">
                        <div class="inline-deletelink"></div>
                    </div>
                </li>
            {% endfor %}
        </ul>
        <div><input type="button" class="add-array-item" value="{% trans "Add another" %}"></div>
    </div>
</div>
{% endspaceless %}

I am basically using input instead of button, and using the built-in inline-deletelink image instead of the one you have.

Just by updating the template everything will work. I am running Django 3.1.

Screenshot from 2020-12-08 16-46-06

fields require attr logic error, can't save model

  • Django better admin ArrayField version: latest
  • Django version:2.1.7
  • Python version:3.7.3
  • Operating System: Debian

Description

Can't save model, I think there has a logic error.

        if errors:
            raise forms.ValidationError(list(chain.from_iterable(errors)))
        if cleaned_data and self.required:
            raise forms.ValidationError(self.error_messages["required"])
        return cleaned_data

this line

      if cleaned_data and self.required:

should be

     if not cleaned_data and self.required:

Hi file fields as well as choices in charfields dont work properly

  • Django better admin ArrayField version:
  • Django version:
  • Python version:
  • Operating System:

Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

Missing staticfiles manifest entry

  • Django better admin ArrayField version: 1.0.2
  • Django version: 2.2
  • Python version: 3.7
  • Operating System: Alpine Linux

Description

Same as #5, literally, but with debug output.

Running collectstatic crashes because of static() call in the admin mixin. The mixin is imported in the admin.py modules, which are autodiscovered during django startup time.

What I Did

Setting:

STATICFILES_STORAGE = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"

python src/manage.py collectstatic --noinput
Traceback (most recent call last):
  File "src/manage.py", line 24, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute
    django.setup()
  File "/usr/local/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
  File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/apps.py", line 24, in ready
    self.module.autodiscover()
  File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
    autodiscover_modules('admin', register_to=site)
  File "/usr/local/lib/python3.7/site-packages/django/utils/module_loading.py", line 47, in autodiscover_modules
    import_module('%s.%s' % (app_config.name, module_to_search))
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/app/src/openzaak/components/catalogi/admin/__init__.py", line 2, in <module>
    from .catalogus import *  # noqa
  File "/app/src/openzaak/components/catalogi/admin/catalogus.py", line 10, in <module>
    from .zaken import ZaakTypeAdmin
  File "/app/src/openzaak/components/catalogi/admin/zaken.py", line 4, in <module>
    from django_better_admin_arrayfield.admin.mixins import DynamicArrayMixin
  File "/usr/local/lib/python3.7/site-packages/django_better_admin_arrayfield/admin/mixins.py", line 4, in <module>
    class DynamicArrayMixin:
  File "/usr/local/lib/python3.7/site-packages/django_better_admin_arrayfield/admin/mixins.py", line 5, in DynamicArrayMixin
    class Media:
  File "/usr/local/lib/python3.7/site-packages/django_better_admin_arrayfield/admin/mixins.py", line 6, in Media
    js = (static("js/min/django_better_admin_arrayfield.min.js"),)
  File "/usr/local/lib/python3.7/site-packages/django/templatetags/static.py", line 167, in static
    return StaticNode.handle_simple(path)
  File "/usr/local/lib/python3.7/site-packages/django/templatetags/static.py", line 118, in handle_simple
    return staticfiles_storage.url(path)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/staticfiles/storage.py", line 153, in url
    return self._url(self.stored_name, name, force)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/staticfiles/storage.py", line 132, in _url
    hashed_name = hashed_name_func(*args)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/staticfiles/storage.py", line 420, in stored_name
    raise ValueError("Missing staticfiles manifest entry for '%s'" % clean_name)
ValueError: Missing staticfiles manifest entry for 'js/min/django_better_admin_arrayfield.min.js'

Not working in Inline

  • 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)

Display RadioSelect widget instead TextInput

  • Django better admin ArrayField version:
  • Django version: 2.2.10
  • Python version: 3.7
  • Operating System: Linux

Hi,

I would like to know how to display a RadioSelect instead of a TextInput, can you help me?

Thanks

Possible to Implement within a form?

Ignorant Django user here. I was wondering if it would be somehow possible to implement this within a standard for instead of the admin console.

Travis CI SQLite version problem

  • Django better admin ArrayField version:
  • Django version:
  • Python version:
  • Operating System:

Description

On python 3.6 and 3.7 I am getting
django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.8.2).
On TravisCI

What I Did

I tried installing it with addons:

addons:
  apt:
    sources:
      - travis-ci/sqlite3
    packages:
      - sqlite3

The sources here got ignored

Disallowing sources: travis-ci/sqlite3
To add unlisted APT sources, follow instructions in https://docs.travis-ci.com/user/installing-dependencies#Installing-Packages-with-the-APT-Addon

And with ppa in before_install

before_install:
  # The default version of sqlite on travis doesn't support bulk inserts.
  - sudo apt-add-repository -y ppa:travis-ci/sqlite3
  - sudo apt-get -y update
  - sudo apt-get -y install sqlite3=3.7.15.1-1~travis1

error:

Cannot add PPA: 'ppa:travis-ci/sqlite3'.
Please check that the PPA name or format is correct.

Missing staticfiles manifest entry

  • Django better admin ArrayField version: 1.0.2
  • Django version: 2.2
  • Python version: 3.6
  • Operating System: Amazon Linux

Description

I'm attempting to deploy my app on elastic beanstalk but I get the following error.

ValueError: Missing staticfiles manifest entry for 'js/min/django_better_admin_arrayfield.min.js'

My deployment process does have a collectstatic step, and this is the only package that I've gotten this for.

No .mo file for locales

  • Django better admin ArrayField version: Last version
  • Django version: 2.2
  • Python version: 3.8
  • Operating System: Ubuntu

Description

The locales files located in locale/*/LC_MESSAGES are not compiled in .mo files, so they are not used.
Is it possible to add a compiled version in next release ?

Many thanks !

PyPi website doesn't mention replacing the ArrayField in the model

Hi,

Thanks for this amazing library. I wanted to mention that the PyPi page for this package doesn't mention that the ArrayField in the model should be replaced by the ArrayField in this package (while GitHub does). I found it confusing in the beginning why it didn't work.

I didn't follow the issue template, because this is not a usual issue report. Thought I would mention this since a lot of people would land on the PyPi page as it ranks higher in Google than the Github repo.

Best regards

Adapting widget is not working

  • Django better admin ArrayField version: 1.4.2
  • Django version: 2.1.4
  • Python version: 3.6.9
  • Operating System: Linux

Description and What I did

I was trying to use the DynamicArrayTextareaWidget as described in the documentation:

from django_better_admin_arrayfield.forms.widgets import DynamicArrayTextareaWidget

class MyModelAdmin(OrderedModelAdmin, DynamicArrayMixin):
    ...
    formfield_overrides = {
        DynamicArrayField: {'widget': DynamicArrayTextareaWidget},
    }

I also tried the workflow to create an own widget by following the given documentation:

class MyWidget(DynamicArrayWidget):
    def __init__(self, *args, **kwargs):
        kwargs['subwidget_form'] = MyForm
        super().__init__(*args, **kwargs)

class MyModelAdmin(OrderedModelAdmin, DynamicArrayMixin):
    ...
    formfield_overrides = {
        DynamicArrayField: {'widget': MyWidget},
    }

I use an OrderedModelAdmin instead of model.ModelAdmin.

Using the feature formfield_overrides works for me for models.Charfield etc. but not for the DynamicArrayField. I always get only the forms.TextInput rendered. When debugging, it appears that DynamicArrayTextareaWidget does not even get initialized.

Thanks for your help in advance!

Doesn't support Python 3.9?

  • Django better admin ArrayField version:
  • Django version:
  • Python version:
  • Operating System:

Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

js and css files not loaded

  • Django better admin ArrayField version:1.4.2
  • Django version:3.2.12
  • Python version:3.9.18
  • Operating System:Ubuntu

Description

The style of inputs is not correct and the add another button does not work.

What I Did

I had run Django collectstatic command but it didn't copy any of the files to the static dir
I checked the browser web developer tools network and there is a 404 not found error.
I checked my local version and it is ok even though the CSS and JS files are not in my static files, but in the stage server that responds 404 status code for these two files.

image

image

Remove Debug statements

Description

In the fields.py is a print statement that could spam log files. It should be removed or replaced by logger.debug.

Unable to add an item after removing all items

  • Django better admin ArrayField version: 1.0.2
  • Django version: 2.2.3
  • Python version: 3.6
  • Operating System: Ubuntu 18:04

Description

When removing all items and trying add a new one browser throws an error.

What I Did

Just opened the page and removed all items, then clicked on `Add another` button.
Uncaught TypeError: Cannot read property 'cloneNode' of null
    at HTMLButtonElement.<anonymous> (django_better_admin_arrayfield.min.js:1)


The problem is in these two lines, it tries to clone a non-existing element.

PR is coming soon.

Add button does nothing

  • Django better admin ArrayField version: 1.4.2
  • Django version: 3.1
  • Python version: 3.8.6
  • Operating System: Docker

Installed and configured as per the docs but the Add button does nothing.
How does the static get through?

From chrome
There is no attempt to get a js file
For CSS it tries
http://localhost:8001/static/css/django_better_admin_arrayfield.min.css
which gives a 404

Does static need collection?
I am using django-compressor==2.4 which handles via STATICFILES_FINDERS

The page source looks like this and the js and css give 404 on those locations

<script src="/admin/jsi18n/"></script>
<link href="/static/css/django_better_admin_arrayfield.min.css" type="text/css" media="all" rel="stylesheet">
<script src="/static/admin/js/vendor/jquery/jquery.js"></script>
<script src="/static/js/django_better_admin_arrayfield.min.js"></script>
<script src="/static/admin/js/jquery.init.js"></script>
<script src="/static/admin/js/core.js"></script>
<script src="/static/admin/js/admin/RelatedObjectLookups.js"></script>
<script src="/static/admin/js/actions.js"></script>
<script src="/static/admin/js/urlify.js"></script>
<script src="/static/admin/js/prepopulate.js"></script>
<script src="/static/admin/js/vendor/xregexp/xregexp.js"></script>

Incorrect behavior of widget, while trying to remove all items from arrayfield

  • Django better admin ArrayField version: 1.0.2
  • Django version: 2.2.3
  • Python version: 3.7
  • Operating System: python:alpine (from Dockerfile)

I have found incorrect behavior of widget, while trying to remove all items from arrayfield.

Description

Assuming that:

  • I already have some items in arrayfield widget
  • I want to have None

How to replicate incorrect behavior?
I click "x" button next to item for every item. Widget show no items. I click save and continue editing. Page is reloaded. The items are still there.

How to achieve correct behavior?
I click "x" button next to item for every item except last one. For the last item I clear the input field. Click save and continue editing. All items are gone.

Inline forms not working after django 4.1

  • Django better admin ArrayField version: 1.4.2
  • Django version: 4.1.4
  • Python version: 3.11
  • Operating System: macOS 12.6 (Monterey)

Description

When using a better array field in an inline admin the Add another button does not work on new items. The Uncaught TypeError: Cannot read properties of undefined (reading '0') error is seen in the console when adding a new inline item.

This is caused by changes in django 4.1. From the docs:

Changed in Django 4.1:
In older versions, the event was a jQuery event with $row and formsetName parameters.
It is now a JavaScript CustomEvent with parameters set in event.detail.

Possibly related to some of the issues people are having described in issue #25

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.