diff --git a/.idea/django.iml b/.idea/django.iml
new file mode 100644
index 0000000..f4995de
--- /dev/null
+++ b/.idea/django.iml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
index 105ce2d..991141f 100644
--- a/.idea/inspectionProfiles/profiles_settings.xml
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -1,6 +1,6 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..2848a40
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,114 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "customColor": "",
+ "associatedIndex": 1
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1760248745025
+
+
+ 1760248745025
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/DjangoBlog-master_1/.idea/vcs.xml b/src/DjangoBlog-master_1/.idea/vcs.xml
index 3c7f849..2dd0ec8 100644
--- a/src/DjangoBlog-master_1/.idea/vcs.xml
+++ b/src/DjangoBlog-master_1/.idea/vcs.xml
@@ -1,5 +1,5 @@
-
+ #11
diff --git a/src/DjangoBlog-master_1/DjangoBlog-master/accounts/models.py b/src/DjangoBlog-master_1/DjangoBlog-master/accounts/models.py
index 3baddbb..44adce5 100644
--- a/src/DjangoBlog-master_1/DjangoBlog-master/accounts/models.py
+++ b/src/DjangoBlog-master_1/DjangoBlog-master/accounts/models.py
@@ -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'
diff --git a/src/test.py b/src/test.py
new file mode 100644
index 0000000..e69de29