Compare commits

...

4 Commits

Author SHA1 Message Date
df99d7ae1e setup.sh 已弃用,以README.md为准 2026-02-25 22:27:51 +08:00
06e2813bee 忽略CLAUDE.md 2026-02-25 22:05:44 +08:00
7c49bf3ce4 将127.0.0.1添加至ALLOWED_HOSTS与CSRF_TRUSTED_ORIGINS(example) 2026-02-25 22:05:29 +08:00
0753ab3955 修复主界面总浏览数为0问题 2026-02-25 22:01:58 +08:00
5 changed files with 10 additions and 6 deletions

View File

@@ -13,8 +13,8 @@ EMAIL_HOST_USER=
EMAIL_HOST_PASSWORD=
# Security Settings (for production)
ALLOWED_HOSTS=yourdomain.com,www.yourdomain.com
CSRF_TRUSTED_ORIGINS=https://yourdomain.com,https://www.yourdomain.com
ALLOWED_HOSTS=127.0.0.1,yourdomain.com,www.yourdomain.com
CSRF_TRUSTED_ORIGINS=http://127.0.0.1:8000,https://yourdomain.com,https://www.yourdomain.com
# File Upload Settings
FILE_UPLOAD_MAX_MEMORY_SIZE=5242880

1
.gitignore vendored
View File

@@ -45,3 +45,4 @@ tailwindcss
# Claude Code
.claude/
CLAUDE.md

View File

@@ -68,9 +68,7 @@
<div class="text-gray-400">分类数量</div>
</div>
<div class="text-center">
{% with total_views=artworks.aggregate.total_views %}
<div class="text-3xl font-bold text-blue-400 mb-2">{{ total_views|default:"0" }}</div>
{% endwith %}
<div class="text-3xl font-bold text-blue-400 mb-2">{{ total_views }}</div>
<div class="text-gray-400">总浏览次数</div>
</div>
<div class="text-center">

View File

@@ -1,6 +1,6 @@
from django.shortcuts import render, get_object_or_404, redirect
from django.views.generic import ListView, DetailView
from django.db.models import Q
from django.db.models import Q, Sum
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required
from django.contrib import messages
@@ -12,8 +12,10 @@ from .forms import CommentForm
def index(request):
"""首页视图 - 展示所有作品"""
artworks = Artwork.objects.all().order_by('order', '-created_at')
total_views = artworks.aggregate(total=Sum('view_count'))['total'] or 0
context = {
'artworks': artworks,
'total_views': total_views,
'page_title': 'YITAO-REN GALLERY',
}
return render(request, 'gallery/index.html', context)

View File

@@ -1,5 +1,8 @@
#!/bin/bash
# setup.sh已弃用不建议使用setup.sh进行安装。请使用README.md中的安装步骤进行安装。
# setup.sh is deprecated and not recommended for installation. Please follow the installation steps in README.md instead.
# YITAO-REN GALLERY 项目安装脚本
set -e