Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Assets for Widgets Used in Formsets #5

Open
blasferna opened this issue Jun 29, 2023 · 0 comments
Open

Missing Assets for Widgets Used in Formsets #5

blasferna opened this issue Jun 29, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@blasferna
Copy link
Owner

There's an issue with the package where the necessary CSS and JavaScript dependencies for widgets are not loaded when these widgets are placed in a formset within a form. Please note that this issue does not occur when the same widget is added directly to the main form.

imagen

Steps to Reproduce:

The issue is reproducible using the django-bootstrap-datepicker-plus package with the following steps:

  1. Install the package: pip install django-bootstrap-datepicker-plus

  2. Add it to INSTALLED_APPS:

    INSTALLED_APPS = [
        "bootstrap_datepicker_plus",
    ]
  3. Create a custom widget without redefining the CSS and JavaScript:

    from bootstrap_datepicker_plus.widgets import (
        DatePickerInput,
        TimePickerInput
    )
    
    class DatePickerWidget(DatePickerInput):
        def __init__(self, attrs=None, format=None):
            attrs = attrs or {}
            attrs.update({'class': 'datepicker'})
            super(DatePickerWidget, self).__init__(attrs, format)
  4. Assign the custom widget to a formset example (in this case, PaymentTermForm):

    from demo.widgets import DatePickerWidget
    
    class PaymentTermForm(forms.ModelForm):
        def __init__(self, *args, **kwargs):
            ...
        class Meta:
            model = PaymentTerm
            fields = "__all__"
            widgets = {"due_date": DatePickerWidget}
@blasferna blasferna added the bug Something isn't working label Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant