MemoryError when passing big QuerySet from Views to Template (Django, PostgreSQL) -
i'm building gis-related web application, , way displays contents of database on map pretty straightforward: view collects several (currently 122) geojson files , passes them template. template iterates of them , displays them (using leaflet). however, cannot manage make work, every attempt results in memory error.
the database i'm using postgresql one, in case helps. i'm using textfield in model, possible source of issue?
any advice appreciated :)
the view:
geodata = geojsondata.objects.filter(connection = my_con).iterator() view = "map" return render(request, "map.html", {'geojsondata': geodata})
the template:
{% dat in geojsondata %} {% dat.name name %} {% dat.geodata gj %} {{gj}} l.geojson(name).addto(map); {% endwith %} {% endwith %} {% endfor %}
the model:
class geojsondata(models.model): name = models.charfield(max_length=2000, unique=true) connection= models.foreignkey(connection, related_name='connection', default=1) geodata = models.textfield()
the traceback:
environment: request method: request url: http://127.0.0.1:8000/map/1/ django version: 1.11.4 python version: 3.6.2 installed applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'myapp.apps.myappconfig'] installed middleware: ['django.middleware.security.securitymiddleware', 'django.contrib.sessions.middleware.sessionmiddleware', 'django.middleware.common.commonmiddleware', 'django.middleware.csrf.csrfviewmiddleware', 'django.contrib.auth.middleware.authenticationmiddleware', 'django.contrib.messages.middleware.messagemiddleware', 'django.middleware.clickjacking.xframeoptionsmiddleware'] traceback: file "c:\users\xabi\appdata\local\programs\python\python36-32\lib\site-packages\django\core\handlers\exception.py" in inner 41. response = get_response(request) file "c:\users\xabi\appdata\local\programs\python\python36-32\lib\site-packages\django\core\handlers\base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request) file "c:\users\xabi\appdata\local\programs\python\python36-32\lib\site-packages\django\core\handlers\base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs) file "c:\users\xabi\appdata\local\programs\python\python36-32\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view 23. return view_func(request, *args, **kwargs) file "c:\users\xabi\desktop\...\views.py" in mapa 92. return render(request, "map.html", {'geojsondata': geodata}) file "c:\users\xabi\appdata\local\programs\python\python36-32\lib\site-packages\django\shortcuts.py" in render 31. return httpresponse(content, content_type, status) file "c:\users\xabi\appdata\local\programs\python\python36-32\lib\site-packages\django\http\response.py" in __init__ 303. self.content = content file "c:\users\xabi\appdata\local\programs\python\python36-32\lib\site-packages\django\http\response.py" in content 336. content = self.make_bytes(value) file "c:\users\xabi\appdata\local\programs\python\python36-32\lib\site-packages\django\http\response.py" in make_bytes 247. return bytes(value.encode(self.charset)) file "c:\users\xabi\appdata\local\programs\python\python36-32\lib\site-packages\django\utils\functional.py" in _curried 15. return _curried_func(*(args + moreargs), **dict(kwargs, **morekwargs)) file "c:\users\xabi\appdata\local\programs\python\python36-32\lib\site-packages\django\utils\safestring.py" in _proxy_method 107. return safebytes(data) exception type: memoryerror @ /map/1/ exception value:
Comments
Post a Comment