Changes between Initial Version and Version 16 of Ticket #36441


Ignore:
Timestamp:
Oct 24, 2025, 7:39:46 PM (12 days ago)
Author:
Tim Graham
Comment:

I don't know about that proposal. It seems strange to have to silence warnings for "optional dependencies" that may not be needed. I would like to see my questions in comment:13 answered in order to understand how a "missing GDAL" error would be surfaced to a user.

By the way, despite the lazy loading commit for GEOS, it's still listed as a required dependency. I guess not much of GeoDjango is usable without it.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #36441

    • Property Triage Stage UnreviewedAccepted
    • Property Owner set to Josh Thomas
    • Property Status newassigned
    • Property Has patch set
    • Property Patch needs improvement set
  • Ticket #36441 – Description

    initial v16  
    11I'd like to propose enabling lazy loading of the GDAL library in `django.contrib.gis.gdal`, matching the existing behavior of `django.contrib.gis.geos` with the GEOS library.
    22
    3 Currently, calling `django.setup()` on projects using GeoDjango fails if GDAL is not installed, even when GDAL functionality is not being used. This creates an inconsistency in the GeoDjango framework where the GEOS library supports lazy loading (implemented ~10 years ago) but GDAL does not. The proposed change would implement lazy loading for the GDAL module similar to the existing GEOS implementation, ensuring the GDAL library is only loaded when actually accessed or used.
     3Currently, calling `django.setup()` on projects using GeoDjango fails if GDAL is not installed, even when GDAL functionality is not being used. This creates an inconsistency in the GeoDjango framework where the GEOS library supports lazy loading (implemented in 2015 in 61d09e61f5747d7a70268ca8d5e770486877500b) but GDAL does not. The proposed change would implement lazy loading for the GDAL module similar to the existing GEOS implementation, ensuring the GDAL library is only loaded when actually accessed or used.
    44
    55I have a working proof-of-concept in a [https://github.com/joshuadavidthomas/django/tree/lazy-gdal branch] on my fork of the Django repo ready for review ([https://github.com/django/django/compare/main...joshuadavidthomas:django:lazy-gdal diff]).
     
    88
    99I have created both a [https://forum.djangoproject.com/t/proposal-lazy-loading-for-django-contrib-gis-gdal/41198 forum post] and an [https://github.com/django/new-features/issues/42 issue on django/new-features]. Both have only been open for a few days, so not a ton of time for people to see them. However, the initial reception has been positive, with the forum post receiving several likes and the new-features issue getting only thumbs-up reactions.
     10
     11History: GDAL was initially (inadvertently) required before it was made optional in #5433 and then was made required in #26753 in order to simply the code base.
Back to Top