I want to use geographical point in my django app therefor i changed the database engine to spatialite settings.py
"""
Django settings for server project.
Generated by 'django-admin startproject' using Django 4.1.2.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-+r-63iiele&p+irgsm2ojoayyrk2^6($no8%x+^(32s3wvpk7b'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'django.contrib.gis',
'hiketracking.apps.HiketrackingConfig',
'rest_framework',
]
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',
]
ROOT_URLCONF = 'server.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'server.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
DATABASES = {
'default': {
"ENGINE": "django.contrib.gis.db.backends.spatialite",
'NAME': BASE_DIR / 'db.sqlite3',
},
}
# Password validation
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/
STATIC_URL = 'static/'
# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
SPATIALITE_LIBRARY_PATH = '/usr/local/lib/mod_spatialite.dylib'
# Absolute filesystem path to the directory that will hold user-uploaded files.
MEDIA_ROOT = BASE_DIR
model.py
from django.contrib.gis.db import models
# Create your models here.
class Hike(models.Model):
title = models.CharField(max_length=30, unique=True)
length = models.IntegerField()
expected_time = models.IntegerField()
ascent = models.IntegerField()
start_point = models.PointField()
end_point = models.PointField()
description = models.CharField(max_length=200)
track_file = models.FileField(upload_to='tracks')
class HikeReferencePoint(models.Model):
hike = models.ForeignKey(Hike, on_delete=models.CASCADE)
reference_point = models.PointField()
after i run migration i get the fallowing error
Tracking file by folder pattern: migrations
Operations to perform:
Apply all migrations: admin, auth, contenttypes, hiketracking, sessions, sites
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add...Traceback (most recent call last):
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/backends/sqlite3/base.py", line 357, in execute
return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: error in trigger ISO_metadata_reference_row_id_value_insert: no such column: rowid
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/django_manage.py", line 52, in <module>
run_command()
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/django_manage.py", line 46, in run_command
run_module(manage_file, None, '__main__', True)
File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 224, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/Users/md/Desktop/collage/soft2MainProject/server/manage.py", line 22, in <module>
main()
File "/Users/md/Desktop/collage/soft2MainProject/server/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/core/management/base.py", line 402, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/core/management/base.py", line 448, in execute
output = self.handle(*args, **options)
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/core/management/base.py", line 96, in wrapped
res = handle_func(*args, **kwargs)
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 349, in handle
post_migrate_state = executor.migrate(
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 135, in migrate
state = self._migrate_all_forwards(
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
state = migration.apply(state, schema_editor)
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/migrations/migration.py", line 130, in apply
operation.database_forwards(
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/migrations/operations/fields.py", line 235, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/backends/sqlite3/schema.py", line 174, in alter_field
super().alter_field(model, old_field, new_field, strict=strict)
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 788, in alter_field
self._alter_field(
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/backends/sqlite3/schema.py", line 457, in _alter_field
self._remake_table(model, alter_field=(old_field, new_field))
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/backends/sqlite3/schema.py", line 347, in _remake_table
self.alter_db_table(
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/contrib/gis/db/backends/spatialite/schema.py", line 153, in alter_db_table
super().alter_db_table(model, old_db_table, new_db_table, disable_constraints)
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/backends/sqlite3/schema.py", line 121, in alter_db_table
super().alter_db_table(model, old_db_table, new_db_table)
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 606, in alter_db_table
self.execute(
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 199, in execute
cursor.execute(sql, params)
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 103, in execute
return super().execute(sql, params)
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
with self.db.wrap_database_errors:
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
File "/Users/md/Desktop/collage/soft2MainProject/server/venv/lib/python3.10/site-packages/django/db/backends/sqlite3/base.py", line 357, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: error in trigger ISO_metadata_reference_row_id_value_insert: no such column: rowid
I have runed makemigration before migration. my django version is 4.3.1
i have tryed deleting the database and befor migration i have run makemigration. if I only migrate my app it will work but i need the admin panel there for i need to find a way to fix this thank you