diff --git a/django/contrib/gis/gdal/raster/band.py b/django/contrib/gis/gdal/raster/band.py
index f1eb50e..19f39e7 100644
a
|
b
|
|
| 1 | import weakref |
1 | 2 | from ctypes import byref, c_int |
2 | 3 | |
3 | 4 | from django.contrib.gis.gdal.base import GDALBase |
… |
… |
class GDALBand(GDALBase):
|
14 | 15 | Wraps a GDAL raster band, needs to be obtained from a GDALRaster object. |
15 | 16 | """ |
16 | 17 | def __init__(self, source, index): |
17 | | self.source = source |
| 18 | self.source = weakref.proxy(source) |
18 | 19 | self._ptr = capi.get_ds_raster_band(source._ptr, index) |
19 | 20 | |
20 | 21 | @property |
diff --git a/tests/gis_tests/rasterapp/test_rasterfield.py b/tests/gis_tests/rasterapp/test_rasterfield.py
index d1c015f..50d58b4 100644
a
|
b
|
class RasterFieldTest(TransactionTestCase):
|
23 | 23 | r.refresh_from_db() |
24 | 24 | self.assertIsNone(r.rast) |
25 | 25 | |
| 26 | def test_access_band_data_direclty_from_queryset(self): |
| 27 | RasterModel.objects.create(rast=JSON_RASTER) |
| 28 | qs = RasterModel.objects.all() |
| 29 | qs[0].rast.bands[0].data() |
| 30 | |
26 | 31 | def test_model_creation(self): |
27 | 32 | """ |
28 | 33 | Test RasterField through a test model. |