#28074 closed Cleanup/optimization (fixed)
Document template-based widget rendering ramifications for contrib.gis
| Reported by: | Tobi | Owned by: | Tim Graham |
|---|---|---|---|
| Component: | Documentation | Version: | 1.11 |
| Severity: | Normal | Keywords: | geodjango, templates |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
After upgrading from 1.10.7 to 1.11, OSMGeoAdmin with custom map_template throws a TemplateDoesNotExist error.
Consider an OSMGeoAdmin and a simple view:
class FieldAdmin(OSMGeoAdmin):
map_template = 'gis/admin/hello_world.html'
def test_view(request):
return render(request, 'gis/admin/hello_world.html', {})
The template is in project_dir/templates/gis/admin/hello_world.html, and the relevant settings are pretty default:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates'),],
'APP_DIRS': True,
'OPTIONS': {
...
},
},
]
The test_view finds the template and renders fine, while the FieldAdmin cannot find the template. Interestingly, the filesystemloader is being used, but searches a completely wrong directory (ie definitely not my BASE_DIR):
django.template.loaders.filesystem.Loader: /home/ubuntu/env/lib/python3.5/site-packages/django/forms/templates/gis/admin/hello_world.html (Source does not exist)
Downgrading to 1.10.7 solves this issue.
Change History (5)
comment:1 by , 9 years ago
| Summary: | 1.11 GeoDjango admin template loaders change? → 1.11 GeoDjango admin template loaders broken? |
|---|
comment:2 by , 9 years ago
| Component: | GIS → Documentation |
|---|---|
| Owner: | changed from to |
| Status: | new → assigned |
| Summary: | 1.11 GeoDjango admin template loaders broken? → Document template-based widget rendering ramifications for contrib.gis |
| Triage Stage: | Unreviewed → Accepted |
| Type: | Uncategorized → Cleanup/optimization |
There's a backwards-incompatible change that needs to be documented. These widgets now use the form rendering API. You can fix your project by using the
TemplatesSettingrenderer.