Sunday, August 15, 2021

Re: GeoDjango with SpatialLite on Windows 10

OK, I got it.

As it turns out, GDAL has everything you need, including the SQLite database. There is only one important fact, you have to load the DLL prior Django loads his SQLite. Because Django loads the one from Python it self. Therefore i did put the necessary code into the settings.py. Because Django has first to load the settings, before it can load the correct database middleware (SQLite, PostgreSQL, MariaDB,...). The code is in the Picture below.

P.S.: The Tutorial is not quiet accurate. The Geographic Model from there (https://docs.djangoproject.com/en/3.2/ref/contrib/gis/tutorial/#defining-a-geographic-model) should allow NULL for the polygon field:
mpoly = models.MultiPolygonField(null=True)
This is neccessary because the ZIP you offer there has incomplete data. At least good old England (to be precise: United Kingdom) has no pylogon data, maybe some more countries. I didn't check further. Therefore you can't load the "TM_WORLD_BORDERS-0.3.shp" as instructed (https://docs.djangoproject.com/en/3.2/ref/contrib/gis/tutorial/#layermapping).

Should I open a ticket for this, or is this mailing list enough?
settings.png
Tugg Speedman schrieb am Freitag, 13. August 2021 um 18:41:22 UTC+2:
Ah OK, this was helpful. I never thought about this, but as it turns out on Windows, Python ships with it's own compiled version of SQLite (see picture below). This is problematic. If i just swap this DLL with another one, I would change every other Python Script on my machine. Hmm..., is it possible to change some environment Paths in a venv and just point to another DLL? I have to look this up. Thanks a lot Micheal.

sqlite.png

Michael Ross schrieb am Freitag, 13. August 2021 um 00:51:02 UTC+2:
On Thu, 12 Aug 2021 04:15:57 -0700 (PDT)
Tugg Speedman <ts.sim...@gmail.com> wrote:

>
> Hello everyone,
>
> I'm new to GeoDjango and therefore I tried to follow the tutorial
> (https://docs.djangoproject.com/en/3.2/ref/contrib/gis/tutorial/) first.
> But the problem is, it doesn't work with SQLite a.k.a SpatialLite. When I
> try to build the migrations, a Windows error pops up (see picture below).
> It's german and says there is no entry point in gdal301.dll.
>
> So why do I post this problem here in Django mailing list? Because the
> Tutorial is very fuzzy for Spatial & Windows. It basically just says
> download the SQLite files from here: https://www.gaia-gis.it/gaia-sins/
>
> But what to do with this files? Can I put them wherever I want? Do I have
> to add them on System/Python path?
>
> I would really appreciate any help
> Thank you[image: error.png]

Maybe this helps:

https://stackoverflow.com/questions/53682315/error-on-libcurl-dll-when-using-gdal-of-osgeo4w-in-django

TLDR: IntelliJ loads wrong sqlite3.dll?

--
Michael Ross <g...@ross.cx>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e0fb9baa-dbcb-4d6a-a566-a91c7b8d362cn%40googlegroups.com.

No comments:

Post a Comment