#28088 closed Bug (invalid)
Overriding the built-in Django form widget HTML doesn't work
Reported by: | Daniel Greenfeld | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 1.11 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
After multiple attempts following the documentation and peering into the source code, I can't override built-in widget's HTML.
Reference documentation:
- https://docs.djangoproject.com/en/1.11/ref/forms/renderers/#overriding-built-in-widget-templates
- https://docs.djangoproject.com/en/1.11/ref/forms/renderers/#templatessetting
This test case pares down the problem to the barest minimum example:
https://github.com/pydanny/django-widget-override-test-case
Change History (4)
comment:1 by , 8 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 8 years ago
Diff to the referenced project to get it working:
diff --git a/sample/settings.py b/sample/settings.py index 354d15a..3d87369 100644 --- a/sample/settings.py +++ b/sample/settings.py @@ -51,11 +51,12 @@ MIDDLEWARE = [ ] ROOT_URLCONF = 'sample.urls' +FORM_RENDERER = 'django.forms.renderers.TemplatesSetting' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': ['django/forms/templates', 'templates'], + 'DIRS': [BASE_DIR, 'templates'], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [
comment:3 by , 8 years ago
Perhaps specifying that FORM_RENDERER = 'django.forms.renderers.TemplatesSetting'
in a much more obvious way?
Launching TSD 1.11 this week so am swamped, but I'll see if I can get a PR in.
comment:4 by , 8 years ago
#28102 is an accepted ticket for the documentation clarification about the need to put the full path to the built-in widget directories in DIRS
.
Two things need changing:
Closing this since it is in the documentation (https://docs.djangoproject.com/en/1.11/ref/forms/renderers/#overriding-built-in-widget-templates):
That said we will happily take PR improving the wording.