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

Changing template for widget rendering not working #806

Open
esseti opened this Issue Mar 29, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@esseti

esseti commented Mar 29, 2018

  • Package version: 1.7.2
  • Django version: 2.0.3
  • Python version: 3.6

Description:

I'm trying to overide the templates for a widget. While with plain Django it works, with crispy forms it seems to ignore my settings. The new template is ignored.
I've had open a question on SO as well https://stackoverflow.com/questions/49538708/template-widget-in-django-2-0-crispy-form (before figuring out that it was a crispy forms issues)

Code

class MultiChoiceFilterWidget(forms.widgets.CheckboxSelectMultiple):
    template_name = 'web_admin/partial/checkbox.html'

class MyChoiceForm(ModelForm):
        class Meta:
            model = MyModel
            fields = ('theField',)
            widgets = {
                'theField': MultiChoiceFilterWidget,
            }

everything is set up properly

@zoidbergwill

This comment has been minimized.

Contributor

zoidbergwill commented Apr 6, 2018

Hi @esseti

Thanks for your bug report. I'll see if I can reproduce it.

@zoidbergwill

This comment has been minimized.

Contributor

zoidbergwill commented Apr 6, 2018

So I've achieved a similar thing previously doing the following:

class GroupForm(ModelForm):
    deadline = forms.DateField(
        widget=forms.TextInput(
            attrs={'type': 'date'}
        )
    )
@zoidbergwill

This comment has been minimized.

Contributor

zoidbergwill commented Apr 6, 2018

Would it be possible to make an example project that reproduces this issue? If it's easier, it can be a branch on https://github.com/django-crispy-forms/crispy-test-project

@carltongibson

This comment has been minimized.

Collaborator

carltongibson commented Apr 7, 2018

This looks to me like an incompatibility between Django's new template based widget rendering and Crispy Form's own rendering, which predates that by some time.

@esseti

This comment has been minimized.

esseti commented Apr 8, 2018

I'll try to create the example, but I'm rathere busy this week.
I'll look into suggestion from @carltongibson asap, for time being, since my form is just 1 widget, i solved the situation by not using crispy for that form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment