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

No use of default rendering? #74

Open
ddahan opened this issue Oct 10, 2022 · 1 comment
Open

No use of default rendering? #74

ddahan opened this issue Oct 10, 2022 · 1 comment

Comments

@ddahan
Copy link

ddahan commented Oct 10, 2022

Django version : 4.1

I used a MultiModelForm and everything seems to work, except that it does not use the right rendering engine.

My project is configured in settings.py with :

# https://docs.djangoproject.com/en/dev/ref/settings/#form-renderer
FORM_RENDERER = "django.forms.renderers.TemplatesSetting"

That way, any normal Django Form or ModelForm object is rendered, using the template found in django/forms/default.html (what I want).

But I don't get that behaviour using a MultiModelForm, it seems it uses a as_table() Django rendering.
How should I configure my project sothat all forms (django and multiforms) use my default template?

@ddahan ddahan changed the title Support of Django 4.0 template_name attribute? No use of default rendering? Oct 10, 2022
@k4ml
Copy link

k4ml commented Nov 26, 2023

I created base class that all my forms will inherit:-

class MultiForm():
    def __str__(self):
        return mark_safe(''.join(form.render() for form in self.forms.values()))

Then each form will extend it as:-

class PatientUpdateForm(MultiForm, MultiModelForm):
    form_classes = OrderedDict((
        ("account", AccountForm),
        ("patient", PatientForm),
    ))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants