Skip to content

Instantly share code, notes, and snippets.

@smithdc1
smithdc1 / Example.sql
Created July 3, 2025 06:09
PostGIS and GEOS 3.13
-- Enable PostGIS extension
CREATE EXTENSION IF NOT EXISTS postgis;
-- Create City table with PostGIS geometry column
CREATE TABLE City (
ID SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
point GEOMETRY(POINT, 4326)
);
@smithdc1
smithdc1 / gist:86ff4bb4ef27dd975a93d3105d0bebdd
Created June 22, 2025 19:39
django postgis 3.5 and geos 3.13 failure
python : Creating test database for alias 'default'...
At line:1 char:1
+ python .\runtests.py gis_tests.geoapp.tests.GeoLookupTest.test_relate ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Creating test d...as 'default'...:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
E
======================================================================
@smithdc1
smithdc1 / gist:00c8464c2d162b214520680fd5cee037
Created June 7, 2025 13:34
Benchmark for tokenizing a Django Template.
import timeit
crispy = """{% load crispy_forms_field %}
{% if field.is_hidden %}
{{ field }}
{% else %}
{% if field|is_checkbox and tag != "td" %}
<div class="mb-3{% if 'form-horizontal' in form_class %} row{% endif %}">
{% if label_class %}
@smithdc1
smithdc1 / django_sphinx_inventory.md
Created April 4, 2025 09:24
Django Sphinx Inventory
Location Name Type Reference
@smithdc1
smithdc1 / django_sphinx_inventory.md
Created April 4, 2025 09:24
Django Sphinx Inventory
Location Name Type Reference
@smithdc1
smithdc1 / django_sphinx_inventory.md
Created April 4, 2025 09:24
Django Sphinx Inventory
Location Name Type Reference
'PCIDSK'
'netCDF'
'PDS4'
'VICAR'
'JP2OpenJPEG'
'PDF'
'MBTiles'
'EEDA'
'OGCAPI'
'ESRI Shapefile'
@smithdc1
smithdc1 / gist:602ed0eec628746de54f98b67b533f74
Last active February 24, 2022 08:07
Django tests 24th Feb
(django) PS C:\Users\smith\PycharmProjects\django\tests> python .\runtests.py --shuffle
Testing against Django installed in 'c:\users\smith\pycharmprojects\django\django' with up to 8 processes
Using shuffle seed: 2714725009 (generated)
Found 15614 test(s).
Creating test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
======================================================================
ERROR: test_bulk_update (postgres_tests.test_bulk_update.BulkSaveTests) [<object object at 0x000002D559D6DFE0>] (model=<class 'postgres_tests.models.HStoreModel'>, field='field')
----------------------------------------------------------------------
Traceback (most recent call last):
File "c:\users\smith\pycharmprojects\django\django\db\backends\utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: can't adapt type 'dict'
The above exception was the direct cause of the following exception:
@smithdc1
smithdc1 / class.patch
Created October 26, 2021 14:57
Patch to add class level attributes for error_css_class and required_css_class
commit 554a7430a2947f67e2316a6775654c66070d75a2
Author: David Smith <[email protected]>
Date: Tue Oct 26 15:55:57 2021 +0100
Sample class attribute patch
diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py
index 5bbfcbe41c..a971407d0c 100644
--- a/django/forms/boundfield.py
+++ b/django/forms/boundfield.py