From 10419fc80456f2e1192bc457fe84c862ad05173a Mon Sep 17 00:00:00 2001 From: bettleChen <2207153529@qq.com> Date: Tue, 5 Sep 2023 17:53:40 +0800 Subject: [PATCH] update setting and urls add code to __init__.py by pymysql_db --- EduSystemServer/EduSystemServer/__init__.py | 2 ++ EduSystemServer/EduSystemServer/settings.py | 17 +++++++++++------ EduSystemServer/EduSystemServer/urls.py | 5 ++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/EduSystemServer/EduSystemServer/__init__.py b/EduSystemServer/EduSystemServer/__init__.py index e69de29..c45523b 100644 --- a/EduSystemServer/EduSystemServer/__init__.py +++ b/EduSystemServer/EduSystemServer/__init__.py @@ -0,0 +1,2 @@ +import pymysql +pymysql.install_as_MySQLdb() \ No newline at end of file diff --git a/EduSystemServer/EduSystemServer/settings.py b/EduSystemServer/EduSystemServer/settings.py index 1a241e3..69bb3c6 100644 --- a/EduSystemServer/EduSystemServer/settings.py +++ b/EduSystemServer/EduSystemServer/settings.py @@ -25,7 +25,7 @@ SECRET_KEY = 'q63j-o65lzp68yb$%gxz!w@74r@9xubd(66e_@+cfk$ornl(*%' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ["*"] # Application definition @@ -37,6 +37,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'API' ] MIDDLEWARE = [ @@ -75,8 +76,12 @@ WSGI_APPLICATION = 'EduSystemServer.wsgi.application' DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + 'ENGINE': 'django.db.backends.mysql', + 'NAME': "edu_sys", + 'USER': "root", + 'PASSWORD': "cyh0110", + 'HOST': "localhost", + 'PORT': 3306, } } @@ -103,15 +108,15 @@ AUTH_PASSWORD_VALIDATORS = [ # Internationalization # https://docs.djangoproject.com/en/2.2/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = 'zh-Hans' -TIME_ZONE = 'UTC' +TIME_ZONE = 'Asia/Shanghai' USE_I18N = True USE_L10N = True -USE_TZ = True +USE_TZ = False # Static files (CSS, JavaScript, Images) diff --git a/EduSystemServer/EduSystemServer/urls.py b/EduSystemServer/EduSystemServer/urls.py index 4b0d8b6..d16d836 100644 --- a/EduSystemServer/EduSystemServer/urls.py +++ b/EduSystemServer/EduSystemServer/urls.py @@ -14,8 +14,11 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import path, include + +import API.urls urlpatterns = [ path('admin/', admin.site.urls), + path('api/', include(("API.urls", "api"), namespace="api")), ]