From 9351de028a63679d06ab4bff02734559adeb8c58 Mon Sep 17 00:00:00 2001 From: Joakim Saario Date: Wed, 11 Oct 2023 12:28:20 +0200 Subject: [PATCH] Use BigAutoField for djedi.backends.django.db.models.Node --- djedi/backends/django/db/models.py | 1 + djedi/migrations/0003_alter_node_id.py | 19 ++++++ example/example/settings.py | 92 +++++++++++++------------- 3 files changed, 66 insertions(+), 46 deletions(-) create mode 100644 djedi/migrations/0003_alter_node_id.py diff --git a/djedi/backends/django/db/models.py b/djedi/backends/django/db/models.py index 63cfe7cb..146a78bb 100644 --- a/djedi/backends/django/db/models.py +++ b/djedi/backends/django/db/models.py @@ -2,6 +2,7 @@ class Node(models.Model): + id = models.BigAutoField(primary_key=True) key = models.CharField(max_length=255, db_index=True) content = models.TextField(blank=True) diff --git a/djedi/migrations/0003_alter_node_id.py b/djedi/migrations/0003_alter_node_id.py new file mode 100644 index 00000000..82f2e945 --- /dev/null +++ b/djedi/migrations/0003_alter_node_id.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.6 on 2023-10-11 10:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("djedi", "0002_auto_20190722_1447"), + ] + + operations = [ + migrations.AlterField( + model_name="node", + name="id", + field=models.BigAutoField( + auto_created=True, primary_key=True, serialize=False, verbose_name="ID" + ), + ), + ] diff --git a/example/example/settings.py b/example/example/settings.py index d5fc5d21..d56e5db7 100644 --- a/example/example/settings.py +++ b/example/example/settings.py @@ -16,72 +16,74 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" + # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'jf_&sn#&5gb7n510ji#9m7^@@-w@g%f(j0y=@=)pmvpc@4ia0)' +SECRET_KEY = "jf_&sn#&5gb7n510ji#9m7^@@-w@g%f(j0y=@=)pmvpc@4ia0)" # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = ['*'] +ALLOWED_HOSTS = ["*"] # Application definition INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - 'corsheaders', - 'djedi', - 'example', + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "corsheaders", + "djedi", + "example", ] MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'corsheaders.middleware.CorsMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'djedi.middleware.translation.DjediTranslationMiddleware', + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "corsheaders.middleware.CorsMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", + "djedi.middleware.translation.DjediTranslationMiddleware", ] -ROOT_URLCONF = 'example.urls' +ROOT_URLCONF = "example.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', + "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 = 'example.wsgi.application' +WSGI_APPLICATION = "example.wsgi.application" # Database # https://docs.djangoproject.com/en/dev/ref/settings/#databases DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": os.path.join(BASE_DIR, "db.sqlite3"), } } @@ -95,9 +97,9 @@ # Internationalization # https://docs.djangoproject.com/en/dev/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = "en-us" -TIME_ZONE = 'UTC' +TIME_ZONE = "UTC" USE_I18N = True @@ -109,31 +111,29 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/dev/howto/static-files/ -STATIC_URL = '/static/' -MEDIA_URL = '/media/' +STATIC_URL = "/static/" +MEDIA_URL = "/media/" -STATIC_ROOT = '/static/' -MEDIA_ROOT = '/media/' +STATIC_ROOT = "/static/" +MEDIA_ROOT = "/media/" # To test if collectstatic with ManifestStaticFilesStorage works, set `DEBUG = # False` and run: # docker-compose exec django python manage.py collectstatic --no-input # DEBUG = False -STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage' +STATICFILES_STORAGE = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage" # CORS # https://github.com/OttoYiu/django-cors-headers -CORS_ORIGIN_WHITELIST = ( - 'localhost:3000', -) +CORS_ORIGIN_WHITELIST = ("localhost:3000",) CORS_ALLOW_CREDENTIALS = True # Djedi # https://djedi-cms.org/settings.html -DJEDI_XSS_DOMAIN = 'localhost' +DJEDI_XSS_DOMAIN = "localhost" # env DJEDI_THEME=luke docker-compose up -d django -DJEDI_THEME = os.environ.get('DJEDI_THEME') or None +DJEDI_THEME = os.environ.get("DJEDI_THEME") or None