Merge branch 'gjw_branch'

onet
顾婧玟 4 months ago
commit 37d609ca25

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Jinja2" />
<option name="TEMPLATE_FOLDERS">
<list>
<option value="$MODULE_DIR$/src/DjangoBlog-master/DjangoBlog-master/templates" />
</list>
</option>
</component>
</module>

@ -1,6 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
<settings><!-- 配置设置区域 -->
<option name="USE_PROJECT_PROFILE" value="false" /><!-- 配置选项是否使用项目配置文件当前设置为不使用false -->
<version value="1.0" /><!-- 配置版本信息当前版本为1.0 -->
</settings>
</component>

@ -0,0 +1,114 @@
<?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="feebdecb-aab4-468a-89d2-02ab184d6524" name="更改" comment="注释">
<change beforePath="$PROJECT_DIR$/.idea/django.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/django.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/DjangoBlog-master/.idea/inspectionProfiles/profiles_settings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/DjangoBlog-master/.idea/inspectionProfiles/profiles_settings.xml" 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="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="main" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectColorInfo">{
&quot;customColor&quot;: &quot;&quot;,
&quot;associatedIndex&quot;: 1
}</component>
<component name="ProjectId" id="33xBFgI9uhuAj9lNSHkgcMEmGEr" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ModuleVcsDetector.initialDetectionPerformed": "true",
"RunOnceActivity.OpenDjangoStructureViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
"RunOnceActivity.git.unshallow": "true",
"last_opened_file_path": "C:/Users/35500/Desktop/软件工程与方法学/django",
"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",
"vue.rearranger.settings.migration": "true"
}
}]]></component>
<component name="RunManager">
<configuration name="django" type="Python.DjangoServer" factoryName="Django server">
<module name="django" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</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="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-b598e85cdad2-JavaScript-PY-252.25557.178" />
<option value="bundled-python-sdk-ce6832f46686-7b97d883f26b-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-252.25557.178" />
</set>
</attachedChunks>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="默认任务">
<changelist id="feebdecb-aab4-468a-89d2-02ab184d6524" name="更改" comment="" />
<created>1760248745025</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1760248745025</updated>
<workItem from="1760248747064" duration="34000" />
<workItem from="1760248891758" duration="6962000" />
<workItem from="1760271313858" duration="27000" />
<workItem from="1760271342012" duration="835000" />
<workItem from="1760851293582" duration="1237000" />
<workItem from="1760852569906" duration="605000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
</project>

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<project version="4"> #11
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
<mapping directory="$PROJECT_DIR$/DjangoBlog" vcs="Git" />

@ -1,35 +1,53 @@
# 导入Django内置的用户模型基类用于扩展用户功能
from django.contrib.auth.models import AbstractUser
# 导入Django的模型模块用于定义数据库模型
from django.db import models
# 导入reverse函数用于生成URL
from django.urls import reverse
# 导入时区相关函数,用于处理时间字段
from django.utils.timezone import now
# 导入翻译相关工具,用于国际化支持
from django.utils.translation import gettext_lazy as _
# 导入自定义工具函数,用于获取当前站点信息
from djangoblog.utils import get_current_site
# Create your models here.
# 创建模型类
class BlogUser(AbstractUser):
# 昵称字段允许为空max_length指定最大长度_()用于支持国际化翻译
nickname = models.CharField(_('nick name'), max_length=100, blank=True)
# 账号创建时间字段,默认值为当前时间
creation_time = models.DateTimeField(_('creation time'), default=now)
# 最后修改时间字段,默认值为当前时间(通常需要在保存时更新,可能在其他地方处理)
last_modify_time = models.DateTimeField(_('last modify time'), default=now)
# 账号创建来源字段,用于记录用户注册渠道,允许为空
source = models.CharField(_('create source'), max_length=100, blank=True)
def get_absolute_url(self):
return reverse(
'blog:author_detail', kwargs={
'author_name': self.username})
'blog:author_detail', # URL配置中定义的名称
kwargs={'author_name': self.username} # 传递的参数,使用用户名作为标识
)
def __str__(self):
return self.email
def get_full_url(self):
# 获取当前站点的域名(从站点配置中获取)
site = get_current_site().domain
url = "https://{site}{path}".format(site=site,
path=self.get_absolute_url())
# 拼接域名和路径形成完整URL
url = "https://{site}{path}".format(
site=site,
path=self.get_absolute_url()
)
return url
class Meta:
# 排序方式按id降序排列新创建的用户在前
ordering = ['-id']
# 模型的显示名称(单数),支持国际化
verbose_name = _('user')
# 模型的显示名称(复数),支持国际化
verbose_name_plural = verbose_name
# 指定获取最新记录时使用的字段
get_latest_by = 'id'

Loading…
Cancel
Save