修改关于我们页面,优化中英文切换
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
from django.contrib import admin
|
||||
from django.db import models
|
||||
from ckeditor_uploader.widgets import CKEditorUploadingWidget
|
||||
from .models import SiteSettings, Banner
|
||||
|
||||
|
||||
@admin.register(SiteSettings)
|
||||
class SiteSettingsAdmin(admin.ModelAdmin):
|
||||
list_display = ('id',)
|
||||
formfield_overrides = {
|
||||
models.TextField: {'widget': CKEditorUploadingWidget},
|
||||
}
|
||||
fieldsets = (
|
||||
('基础信息', {
|
||||
'fields': ('site_name_zh', 'site_name_en', 'site_logo',
|
||||
@@ -15,6 +20,9 @@ class SiteSettingsAdmin(admin.ModelAdmin):
|
||||
'company_address_zh', 'company_address_en',
|
||||
'company_phone', 'company_email')
|
||||
}),
|
||||
('关于我们', {
|
||||
'fields': ('about_content_zh', 'about_content_en'),
|
||||
}),
|
||||
('社交媒体', {
|
||||
'fields': ('wechat_qr', 'weibo_url'),
|
||||
'classes': ('collapse',)
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 5.0.14 on 2026-08-05 00:51
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='sitesettings',
|
||||
name='about_content_en',
|
||||
field=models.TextField(blank=True, default='', verbose_name='关于我们内容(英文)'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='sitesettings',
|
||||
name='about_content_zh',
|
||||
field=models.TextField(blank=True, default='', verbose_name='关于我们内容(中文)'),
|
||||
),
|
||||
]
|
||||
@@ -28,6 +28,9 @@ class SiteSettings(models.Model):
|
||||
seo_description_zh = models.CharField('默认SEO描述(中文)', max_length=300, blank=True, default='')
|
||||
seo_description_en = models.CharField('默认SEO描述(英文)', max_length=300, blank=True, default='')
|
||||
|
||||
about_content_zh = models.TextField('关于我们内容(中文)', blank=True, default='')
|
||||
about_content_en = models.TextField('关于我们内容(英文)', blank=True, default='')
|
||||
|
||||
class Meta:
|
||||
verbose_name = '网站设置'
|
||||
verbose_name_plural = verbose_name
|
||||
|
||||
@@ -6,6 +6,15 @@
|
||||
{% block content %}
|
||||
<section class="section bg-white py-5">
|
||||
<div class="container">
|
||||
<div class="section-title">
|
||||
<h2>{% trans '关于我们' %}</h2>
|
||||
</div>
|
||||
{% with about_content=site_settings.about_content_zh|default:site_settings.about_content_en %}
|
||||
{% if about_content %}
|
||||
<div class="about-content">
|
||||
{{ about_content|safe }}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="row align-items-center g-5">
|
||||
<div class="col-lg-6">
|
||||
<h2 class="mb-4">{% trans '关于我们' %}</h2>
|
||||
@@ -36,9 +45,12 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{% if not site_settings.about_content_zh and not site_settings.about_content_en %}
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<div class="section-title">
|
||||
@@ -69,4 +81,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
</ul>
|
||||
<form action="{% url 'set_language' %}" method="post" class="lang-switcher ms-lg-3 mt-2 mt-lg-0">
|
||||
{% csrf_token %}
|
||||
<input name="next" type="hidden" value="{{ request.get_full_path }}">
|
||||
<button type="submit" name="language" value="zh-hans" class="btn btn-sm {% if LANGUAGE_CODE == 'zh-hans' %}btn-primary{% else %}btn-outline-primary{% endif %}">中文</button>
|
||||
<button type="submit" name="language" value="en" class="btn btn-sm {% if LANGUAGE_CODE == 'en' %}btn-primary{% else %}btn-outline-primary{% endif %}">EN</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user