Search code examples
djangodjango-cmsdivio

Django-cms aldryn forms


I'm following this tutorial (https://www.django-cms.org/en/blog/2016/02/27/build-a-website-without-knowing-python-django-part-six/) to create custom forms with aldryn-forms but this tutorial, I believe, was made for django-cms.org online service and would like to know how to do the same with a local installation of django-cms. Essentially, I want to know how to define my own "FORM TEMPLATE" for this plugin. Thank you


Solution

  • Once you install Aldryn Forms in your project you can set the ALDRYN_FORMS_TEMPLATES setting in your settings.py with an iterable of tuples mapping the template path with the human readable name of the theme like so:

    ALDRYN_FORMS_TEMPLATES = (
        ('path/to/event_form.html, _('Event only')),
        ('path/to/contact_form.html, _('Contact only')),
    )
    

    This allows content managers to pick this "Event only" template whenever they create an "Event" form and "Contact only" whenever they create a "Contact" form.

    Also you can set the default template using ALDRYN_FORMS_DEFAULT_TEMPLATE