#Overriding builtin form widgets

1 messages · Page 1 of 1 (latest)

vagrant salmon
#

Hi everyone! I have a question for you.

I'm trying to override the builtin widgets defined by django.

I have tried to create a new file inside my app, where I have defined other templates. The path is templates/django/forms/widgets/input.html but it seems it does not work. This should work I think, but it is not 😦

The part I consider relevant from my settings:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

class CustomFormRenderer(TemplatesSetting):
    form_template_name = "form_snippet.html"

FORM_RENDERER = "website.settings.CustomFormRenderer"

Thanks in advance!

keen meadowBOT
ruby knoll
#

How does you INSTALLED_APPS look?

vagrant salmon
#
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.forms',
    'myapp',
]
mortal wedge
#

And your override template is in the myapp folder?

vagrant salmon