This commit is contained in:
2026-03-27 03:08:01 +08:00
parent 29b5466711
commit 36c1575712
39 changed files with 2817 additions and 69 deletions
-10
View File
@@ -1,10 +0,0 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 已忽略包含查询文件的默认文件夹
/queries/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
Generated
-1
View File
@@ -1 +0,0 @@
chunyu_project
+4 -4
View File
@@ -3,9 +3,9 @@
<component name="FacetManager">
<facet type="django" name="Django">
<configuration>
<option name="rootFolder" value="$MODULE_DIR$/../DjangoProject2" />
<option name="rootFolder" value="$MODULE_DIR$" />
<option name="settingsModule" value="chunyu_project/settings.py" />
<option name="manageScript" value="$MODULE_DIR$/../DjangoProject2/manage.py" />
<option name="manageScript" value="$MODULE_DIR$/manage.py" />
<option name="environment" value="&lt;map/&gt;" />
<option name="doNotUseTestRunner" value="false" />
<option name="trackFilePattern" value="migrations" />
@@ -16,14 +16,14 @@
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.12 (DjangoProject2)" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.12 (chunyu_project)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Django" />
<option name="TEMPLATE_FOLDERS">
<list>
<option value="$MODULE_DIR$/../DjangoProject2\templates" />
<option value="$MODULE_DIR$/templates" />
</list>
</option>
</component>
+18
View File
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="dataSourceStorageLocal" created-in="PY-253.31033.139">
<data-source name="db.sqlite3" uuid="5d549d8f-5ef2-47b0-97e6-f6c77b1b0b38">
<database-info product="SQLite" version="3.51.1" jdbc-version="4.2" driver-name="SQLite JDBC" driver-version="3.51.1.0" dbms="SQLITE" exact-version="3.51.1" exact-driver-version="3.51">
<identifier-quote-string>&quot;</identifier-quote-string>
</database-info>
<case-sensitivity plain-identifiers="mixed" quoted-identifiers="mixed" />
<secret-storage>master_key</secret-storage>
<auth-provider>no-auth</auth-provider>
<schema-mapping>
<introspection-scope>
<node kind="schema" qname="@" />
</introspection-scope>
</schema-mapping>
</data-source>
</component>
</project>
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="db.sqlite3" uuid="5d549d8f-5ef2-47b0-97e6-f6c77b1b0b38">
<driver-ref>sqlite.xerial</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
<jdbc-url>jdbc:sqlite:C:\Users\12914\PycharmProjects\chunyu_project\db.sqlite3</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,2 @@
#n:main
!<md> [0, 0, null, null, -2147483648, -2147483648]
-12
View File
@@ -1,12 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<list>
<option value="pycups" />
</list>
</option>
</inspection_tool>
</profile>
</component>
+2 -2
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.12 (DjangoProject2)" />
<option name="sdkName" value="Python 3.12 (chunyu_project)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (DjangoProject2)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (chunyu_project)" project-jdk-type="Python SDK" />
</project>
+159
View File
@@ -0,0 +1,159 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="a7465ceb-8d86-4d89-899e-8242cccf605d" name="更改" comment="">
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Pipfile" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Pipfile.lock" afterDir="false" />
<change afterPath="$PROJECT_DIR$/api/urls.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/api/views/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/app/urls.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/user/urls.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.gitignore" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.name" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/chunyu_project.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/chunyu_project.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/app/apps.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/apps.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/models.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/models.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/tests.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/tests.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/chunyu_project/asgi.py" beforeDir="false" afterPath="$PROJECT_DIR$/chunyu_project/asgi.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/chunyu_project/settings.py" beforeDir="false" afterPath="$PROJECT_DIR$/chunyu_project/settings.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/chunyu_project/urls.py" beforeDir="false" afterPath="$PROJECT_DIR$/chunyu_project/urls.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/chunyu_project/wsgi.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/db.sqlite3" beforeDir="false" afterPath="$PROJECT_DIR$/api/views/GetIPDataView.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="DjangoConsoleOptions" custom-start-script="import sys; print('Python %s on %s' % (sys.version, sys.platform))&#10;import django; print('Django %s' % django.get_version())&#10;sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS])&#10;if 'setup' in dir(django): django.setup()&#10;import django_manage_shell; django_manage_shell.run(PROJECT_ROOT)">
<option name="myCustomStartScript" value="import sys; print('Python %s on %s' % (sys.version, sys.platform))&#10;import django; print('Django %s' % django.get_version())&#10;sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS])&#10;if 'setup' in dir(django): django.setup()&#10;import django_manage_shell; django_manage_shell.run(PROJECT_ROOT)" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="McpProjectServerCommands">
<commands />
<urls />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 7
}</component>
<component name="ProjectId" id="3BR0h7s1ljtKi5ccdljqXDckjSM" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"Django 服务器.chunyu_project.executor": "Run",
"ModuleVcsDetector.initialDetectionPerformed": "true",
"Notification.DisplayName-DoNotAsk-DatabaseConfigFileWatcher.found": "发现新的/更新的数据库配置",
"Notification.DoNotAsk-DatabaseConfigFileWatcher.found": "true",
"Python.tests.executor": "Run",
"RunOnceActivity.MCP Project settings loaded": "true",
"RunOnceActivity.OpenDjangoStructureViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
"RunOnceActivity.git.unshallow": "true",
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
"git-widget-placeholder": "main",
"last_opened_file_path": "C:/Users/12914/PycharmProjects/chunyu_project/user",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable",
"vue.rearranger.settings.migration": "true"
},
"keyToStringList": {
"DatabaseDriversLRU": [
"sqlite"
]
}
}]]></component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\12914\PycharmProjects\chunyu_project\user" />
<recent name="C:\Users\12914\PycharmProjects\chunyu_project\chunyu_project" />
<recent name="C:\Users\12914\PycharmProjects\chunyu_project\api" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="C:\Users\12914\PycharmProjects\chunyu_project\user" />
<recent name="C:\Users\12914\PycharmProjects\chunyu_project\app" />
<recent name="C:\Users\12914\PycharmProjects\chunyu_project\user\models" />
<recent name="C:\Users\12914\PycharmProjects\chunyu_project\chunyu_project" />
<recent name="C:\Users\12914\PycharmProjects\chunyu_project\models\user" />
</key>
</component>
<component name="RunManager">
<configuration name="chunyu_project" type="Python.DjangoServer" factoryName="Django server">
<module name="chunyu_project" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
<env name="DJANGO_SETTINGS_MODULE" value="chunyu_project.settings" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="" />
<option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="RUN_TOOL" value="" />
<option name="launchJavascriptDebuger" value="false" />
<option name="port" value="8000" />
<option name="host" value="" />
<option name="additionalOptions" value="" />
<option name="browserUrl" value="" />
<option name="runTestServer" value="false" />
<option name="runNoReload" value="false" />
<option name="useCustomRunCommand" value="false" />
<option name="customRunCommand" value="" />
<method v="2" />
</configuration>
</component>
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-js-predefined-d6986cc7102b-9b0f141eb926-JavaScript-PY-253.31033.139" />
<option value="bundled-python-sdk-2653e85de345-6d6dccd035ac-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-253.31033.139" />
</set>
</attachedChunks>
</component>
<component name="SvnConfiguration">
<configuration>C:\Users\12914\AppData\Roaming\Subversion</configuration>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="默认任务">
<changelist id="a7465ceb-8d86-4d89-899e-8242cccf605d" name="更改" comment="" />
<created>1774436691939</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1774436691939</updated>
<workItem from="1774436692980" duration="11637000" />
<workItem from="1774474993123" duration="3364000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/chunyu_project$tests.coverage" NAME="tests 覆盖结果" MODIFIED="1774462107469" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/app" />
</component>
</project>
+14
View File
@@ -0,0 +1,14 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
django = "==4.2.29"
djangorestframework = "==3.17.1"
[dev-packages]
[requires]
python_version = "3.12"
python_full_version = "3.12.10"
Generated
+64
View File
@@ -0,0 +1,64 @@
{
"_meta": {
"hash": {
"sha256": "2261b9cfef97e6fd2579aae2dd07367326124e96a21f016cc0bd771db5d7213d"
},
"pipfile-spec": 6,
"requires": {
"python_full_version": "3.12.10",
"python_version": "3.12"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"asgiref": {
"hashes": [
"sha256:5f184dc43b7e763efe848065441eac62229c9f7b0475f41f80e207a114eda4ce",
"sha256:e8667a091e69529631969fd45dc268fa79b99c92c5fcdda727757e52146ec133"
],
"markers": "python_version >= '3.9'",
"version": "==3.11.1"
},
"django": {
"hashes": [
"sha256:074d7c4d2808050e528388bda442bd491f06def4df4fe863f27066851bba010c",
"sha256:86d91bc8086569c8d08f9c55888b583a921ac1f95ed3bdc7d5659d4709542014"
],
"index": "pypi",
"markers": "python_version >= '3.8'",
"version": "==4.2.29"
},
"djangorestframework": {
"hashes": [
"sha256:a6def5f447fe78ff853bff1d47a3c59bf38f5434b031780b351b0c73a62db1a5",
"sha256:c3c74dd3e83a5a3efc37b3c18d92bd6f86a6791c7b7d4dff62bb068500e76457"
],
"index": "pypi",
"markers": "python_version >= '3.10'",
"version": "==3.17.1"
},
"sqlparse": {
"hashes": [
"sha256:12a08b3bf3eec877c519589833aed092e2444e68240a3577e8e26148acc7b1ba",
"sha256:e20d4a9b0b8585fdf63b10d30066c7c94c5d7a7ec47c889a2d83a3caa93ff28e"
],
"markers": "python_version >= '3.8'",
"version": "==0.5.5"
},
"tzdata": {
"hashes": [
"sha256:06a47e5700f3081aab02b2e513160914ff0694bce9947d6b76ebd6bf57cfc5d1",
"sha256:de39c2ca5dc7b0344f2eba86f49d614019d29f060fc4ebc8a417896a620b56a7"
],
"markers": "python_version >= '2'",
"version": "==2025.3"
}
},
"develop": {}
}
View File
+3
View File
@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.
+6
View File
@@ -0,0 +1,6 @@
from django.apps import AppConfig
class ApiConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'api'
View File
+3
View File
@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.
+3
View File
@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.
+7
View File
@@ -0,0 +1,7 @@
from django.contrib import admin
from django.urls import path, include
from .views.GetIPDataView import GetIPData
urlpatterns = [
path("getIpData/", GetIPData.as_view()),
]
View File
+1
View File
@@ -2,4 +2,5 @@ from django.apps import AppConfig
class AppConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'app'
-3
View File
@@ -1,3 +0,0 @@
from django.db import models
# Create your models here.
-3
View File
@@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.
+6
View File
@@ -0,0 +1,6 @@
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
]
+2 -11
View File
@@ -1,16 +1,7 @@
"""
ASGI config for chunyu_project project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/6.0/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'chunyu_project.settings')
application = get_asgi_application()
# Django 默认 ASGI 应用
application = get_asgi_application()
+133 -6
View File
@@ -11,38 +11,165 @@ https://docs.djangoproject.com/en/6.0/ref/settings/
"""
from pathlib import Path
import os
# 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/6.0/howto/deployment/checklist/
# 安全设置
SECURE_SSL_REDIRECT = False
SESSION_COOKIE_SECURE = False
CSRF_COOKIE_SECURE = False
SECURE_HSTS_SECONDS = 31536000
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_HSTS_PRELOAD = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-j+-psq=m++l7hup73k1eg+wm-b&2_)!+_^o=6(=xc$1px*kqt@'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# 生产环境配置
if not DEBUG:
# 从环境变量获取,并过滤空值
cors_env = os.environ.get('CORS_ALLOWED_ORIGINS', '')
if cors_env:
# 解析并验证每个 origin
allowed_origins = []
for origin in cors_env.split(','):
origin = origin.strip()
if origin: # 非空
# 确保有协议(http:// 或 https://)
if not origin.startswith(('http://', 'https://')):
# 自动添加 https://
origin = f'https://{origin}'
allowed_origins.append(origin)
# Application definition
CORS_ALLOWED_ORIGINS = allowed_origins
CORS_ALLOW_ALL_ORIGINS = False
else:
# 如果没有设置,使用默认
CORS_ALLOWED_ORIGINS = []
CORS_ALLOW_ALL_ORIGINS = False
else:
# 开发环境
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOWED_ORIGINS = []
ALLOWED_HOSTS = ["*"]
CORS_ALLOWED_ORIGINS = [
"http://localhost:3000", # 例如:您的React/Vue开发服务器
"http://127.0.0.1:3000",
]
# CORS设置
CORS_ALLOW_ALL_ORIGINS = False
# 允许凭据
CORS_ALLOW_CREDENTIALS = True
# 允许的请求头
CORS_ALLOW_HEADERS = [
'accept',
'accept-encoding',
'authorization',
'content-type',
'dnt',
'origin',
'user-agent',
'x-csrftoken',
'x-requested-with',
]
# 允许的 HTTP 方法
CORS_ALLOW_METHODS = [
'DELETE',
'GET',
'OPTIONS',
'PATCH',
'POST',
'PUT',
]
CORS_PREFLIGHT_MAX_AGE = 86400
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': [
'rest_framework.renderers.JSONRenderer',
],
'DEFAULT_PARSER_CLASSES': [
'rest_framework.parsers.JSONParser',
],
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework_simplejwt.authentication.JWTAuthentication',
'rest_framework.authentication.SessionAuthentication',
# 如果您不需要标准的TokenAuthentication,可以移除下面这行
# 'rest_framework.authentication.TokenAuthentication',
],
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
],
}
from datetime import timedelta
# Simple JWT 设置
SIMPLE_JWT = {
'ACCESS_TOKEN_LIFETIME': timedelta(minutes=60), # 访问令牌有效期
'REFRESH_TOKEN_LIFETIME': timedelta(days=7), # 刷新令牌有效期
'ROTATE_REFRESH_TOKENS': True, # 刷新访问令牌时返回新刷新令牌
'BLACKLIST_AFTER_ROTATION': True, # 启用黑名单应用(需安装django-rest-framework-simplejwt.token_blacklist)
'UPDATE_LAST_LOGIN': True, # 更新用户最后登录时间
'ALGORITHM': 'HS256', # 加密算法
'SIGNING_KEY': SECRET_KEY, # 签名密钥,使用您的SECRET_KEY
'VERIFYING_KEY': None,
'AUDIENCE': None,
'ISSUER': None,
'AUTH_HEADER_TYPES': ('Bearer',), # 认证头前缀,通常是`Bearer`
'AUTH_HEADER_NAME': 'HTTP_AUTHORIZATION',
'USER_ID_FIELD': 'id', # 用户模型标识字段
'USER_ID_CLAIM': 'user_id',
}
AUTH_USER_MODEL = 'user.FUser'
INSTALLED_APPS = [
'app.apps.AppConfig',
"user.apps.UserConfig",
"api.apps.ApiConfig",
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app.apps.AppConfig',
# 第三方应用
'rest_framework',
'rest_framework_simplejwt',
'corsheaders',
'channels',
'django_filters',
'drf_yasg',
'django_extensions',
]
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',
@@ -68,7 +195,7 @@ TEMPLATES = [
},
]
WSGI_APPLICATION = 'chunyu_project.wsgi.application'
ASGI_APPLICATION = 'chunyu_project.asgi.application'
# Database
+7 -1
View File
@@ -15,8 +15,14 @@ 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
urlpatterns = [
path('admin/', admin.site.urls),
path('user/', include('user.urls')),
path("api/", include('api.urls')),
path("app/", include('app.urls')),
]
-16
View File
@@ -1,16 +0,0 @@
"""
WSGI config for chunyu_project project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/6.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'chunyu_project.settings')
application = get_wsgi_application()
BIN
View File
Binary file not shown.
View File
View File
+3
View File
@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.
+6
View File
@@ -0,0 +1,6 @@
from django.apps import AppConfig
class UserConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'user'
+47
View File
@@ -0,0 +1,47 @@
# Generated by Django 5.2.12 on 2026-03-25 21:58
import django.contrib.auth.models
import django.contrib.auth.validators
import django.utils.timezone
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
]
operations = [
migrations.CreateModel(
name='FUser',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')),
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
('phone_number', models.CharField(blank=True, max_length=15, verbose_name='手机号')),
('avatar', models.ImageField(blank=True, null=True, upload_to='avatars/', verbose_name='头像')),
('bio', models.TextField(blank=True, max_length=500, verbose_name='个人简介')),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')),
],
options={
'verbose_name': 'user',
'verbose_name_plural': 'users',
'abstract': False,
},
managers=[
('objects', django.contrib.auth.models.UserManager()),
],
),
]
View File
+18
View File
@@ -0,0 +1,18 @@
from django.contrib.auth.models import AbstractUser
from django.db import models
class FUser(AbstractUser):
phone_number = models.CharField(max_length=15, blank=True, verbose_name='手机号')
avatar = models.ImageField(upload_to='avatars/', blank=True, null=True, verbose_name='头像')
bio = models.TextField(max_length=500, blank=True, verbose_name='个人简介')
# class Meta:
# # 定义在管理后台显示的名称
# verbose_name = '用户'
# verbose_name_plural = verbose_name
def __str__(self):
return self.username
+3
View File
@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.
+16
View File
@@ -0,0 +1,16 @@
from django.contrib import admin
from django.urls import path, include
from rest_framework_simplejwt.views import (
TokenObtainPairView,
TokenRefreshView,
TokenVerifyView,
)
urlpatterns = [
# JWT 认证接口
path('user/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
path('user/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
path('user/token/verify/', TokenVerifyView.as_view(), name='token_verify'),
]
+15
View File
@@ -0,0 +1,15 @@
from django.urls import path, include
from rest_framework_simplejwt.views import (
TokenObtainPairView,
TokenRefreshView,
TokenVerifyView,
)
urlpatterns = [
# JWT 认证接口
path('user/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
path('user/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
path('user/token/verify/', TokenVerifyView.as_view(), name='token_verify'),
]