Explorar el Código

# feat:完成产品模块

yht hace 2 semanas
padre
commit
002bc667b5

+ 13 - 0
pythonweb/aboutApp/__init__.py

@@ -0,0 +1,13 @@
+from os import path
+from django.apps import AppConfig
+
+VERBOSE_APP_NAME='公司简介'
+
+def get_current_app_name(file):
+    return path.dirname(file).replace('\\','/').split('/')[-1]
+
+class AppVerboseNameConfig(AppConfig):
+    name=get_current_app_name(__file__)
+    verbose_name=VERBOSE_APP_NAME
+
+default_app_config=get_current_app_name(__file__)+'.__init__.AppVerboseNameConfig'

+ 3 - 0
pythonweb/aboutApp/admin.py

@@ -6,3 +6,6 @@ class AwardAdmin(admin.ModelAdmin):
 
 
 admin.site.register(Award, AwardAdmin)
 admin.site.register(Award, AwardAdmin)
 # Register your models here.
 # Register your models here.
+
+admin.site.site_header='企业门户网站后台管理系统'
+admin.site.site_title='企业门户网站后台管理系统'

+ 54 - 0
pythonweb/aboutApp/honor.html

@@ -0,0 +1,54 @@
+{% extends "base.html" %}
+{% load staticfiles %}
+
+{% block title %}
+荣誉资质
+{% endblock %}
+
+{% block content %}
+<!-- 广告横幅 -->
+<div class="container-fluid">
+    <div class="row">
+        <img class="img-responsive model-img" src="{% static 'img/about.jpg' %}">
+    </div>
+</div>
+<!-- 主体内容 -->
+<div class="container">
+    <div class="row row-3">
+        <!-- 侧边导航栏 -->
+        <div class="col-md-3">
+            <div class="model-title">
+                公司简介
+            </div>
+            <div class="model-list">
+                <ul class="list-group">
+                    <li class="list-group-item" id="survey">
+                        <a href="{% url 'aboutApp:survey' %}">企业概况</a>
+                    </li>
+                    <li class="list-group-item" id="honor">
+                        <a href="{% url 'aboutApp:honor' %}">荣誉资质</a>
+                    </li>
+                </ul>
+            </div>
+        </div>
+        <!-- 说明文字和图片 -->
+        <div class="col-md-9">
+            <div class="model-details-title">
+                荣誉资质
+            </div>
+            <div class="row">
+                {% for award in awards %}
+                <div class="col-sm-6 col-md-4">
+                    <div class="thumbnail">
+                        <img src="{{award.photo.url}}">
+                        <div class="caption">
+                            <p>{{award.description}}</p>
+                        </div>
+                    </div>
+                </div>
+                {% endfor %}
+            </div>
+        </div>
+    </div>
+</div>
+{% endblock %}

+ 1 - 1
pythonweb/aboutApp/migrations/0001_initial.py

@@ -1,4 +1,4 @@
-# Generated by Django 2.2.4 on 2026-04-21 03:44
+# Generated by Django 2.2.4 on 2026-04-22 06:23
 
 
 from django.db import migrations, models
 from django.db import migrations, models
 
 

+ 7 - 2
pythonweb/aboutApp/models.py

@@ -2,7 +2,12 @@ from django.db import models
 
 
 class Award(models.Model):
 class Award(models.Model):
     description = models.TextField(max_length=500,blank=True,
     description = models.TextField(max_length=500,blank=True,
-                                   null=True)
-    photo = models.ImageField(upload_to='Award/',blank=True)
+                                   null=True,
+                                   verbose_name='荣誉描述')
+    photo = models.ImageField(upload_to='Award/',blank=True,verbose_name='荣誉照片')
+
+    class Meta:
+        verbose_name='获奖和荣誉'
+        verbose_name_plural='获奖和荣誉'
 
 
 # Create your models here.
 # Create your models here.

+ 9 - 6
pythonweb/aboutApp/views.py

@@ -1,8 +1,9 @@
-from django.shortcuts import render
-from django.shortcuts import HttpResponse
+# from django.shortcuts import render
+# from django.shortcuts import HttpResponse
+from .models import Award
 
 
 
 
-# Create your views here.
+# # Create your views here.
 def survey(request):
 def survey(request):
     html = '<html><body>企业概况</body></html>'
     html = '<html><body>企业概况</body></html>'
     # return HttpResponse(html)
     # return HttpResponse(html)
@@ -11,6 +12,8 @@ def survey(request):
         'sub_menu':'survey',})
         'sub_menu':'survey',})
 
 
 def honor(request):
 def honor(request):
-    html = '<html><body>荣誉资质</body></html>'
-    # return HttpResponse(html)
-    return render(request,'honor.html',{'active_menu':'about','sub_menu':'survey'})
+    # html = '<html><body>荣誉资质</body></html>'
+    # # return HttpResponse(html)
+    # return render(request,'honor.html',{'active_menu':'about','sub_menu':'survey'})
+    awards=Award.objects.all()
+    return render(request,'honor.html',{'active_menu':'about','sub_menu':'honor','award':awards,})

+ 21 - 4
pythonweb/homeApp/templates/home.html

@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!-- <!DOCTYPE html>
 {% load static %}
 {% load static %}
 <html lang="zh-cn">
 <html lang="zh-cn">
 
 
@@ -14,8 +14,8 @@
 </head>
 </head>
 
 
 <body>
 <body>
-    <!-- 导航条 -->
-    <nav class="navbar navbar-default" role="navigation">
+导航条 -->
+    <!-- <nav class="navbar navbar-default" role="navigation">
         <div class="container">
         <div class="container">
             <div class="navbar-header">
             <div class="navbar-header">
                 <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                 <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
@@ -85,4 +85,21 @@
     </nav>
     </nav>
 </body>
 </body>
 
 
-</html>
+</html> --> 
+
+
+
+
+
+
+{% extends "base.html" %}
+{% load static %}
+
+{% block title %}
+首页
+{% endblock %}
+{% block content %}
+<!-- 广告横幅 -->
+ 
+<!-- 主题内容 -->
+{% endblock %}

+ 1 - 1
pythonweb/homeApp/views.py

@@ -6,4 +6,4 @@ from django.shortcuts import HttpResponse
 def home(request):
 def home(request):
     html='<html><body>首页</body></html>'
     html='<html><body>首页</body></html>'
     # return HttpResponse(html)
     # return HttpResponse(html)
-    return render(request, 'home.html')
+    return render(request, 'home.html',{'active_menu':'home'})

+ 104 - 0
pythonweb/productsApp/templates/productList.html

@@ -0,0 +1,104 @@
+{% extends "base.html" %}
+{% load staticfiles %}
+
+{% block title %}
+{{productName}}
+{% endblock %}
+
+{% block content %}
+<link href="{% static 'css/products.css' %}" rel="stylesheet">
+<!-- 广告横幅 -->
+<div class="container-fluid">
+    <div class="row">
+        <img class="img-responsive model-img" src="{% static 'img/products.jpg' %}">
+    </div>
+</div>
+<!-- 主体内容 -->
+<div class="container">
+    <div class="row row-3">
+        <!-- 侧边导航栏 -->
+        <div class="col-md-3">
+            <div class="model-title">
+                产品中心
+            </div>
+            <div class="model-list">
+                <ul class="list-group">
+                    <li class="list-group-item" id="robot">
+                        <a href="{% url 'productsApp:products' 'robot' %}">家用机器人</a>
+                    </li>
+                    <li class="list-group-item" id="monitor">
+                        <a href="{% url 'productsApp:products' 'monitor' %}">智能监控</a>
+                    </li>
+                    <li class="list-group-item" id="face">
+                        <a href="{% url 'productsApp:products' 'face' %}">
+                            人脸识别解决方案</a>
+                    </li>
+                </ul>
+            </div>
+        </div>
+        <!-- 说明文字和图片 -->
+        <div class="col-md-9">
+            <div class="model-details-title">
+                {{productName}}
+            </div>
+            <!-- 此处填入产品列表内容 -->
+            <div class="model-details">
+                {% for product in productList %}
+                <div class="row">
+                    <div class="col-md-6">
+                        {% for img in product.productImgs.all %}
+                        {% if forloop.first %}
+                        <a href="{% url 'productsApp:productDetail' product.id %}" class="thumbnail row-4">
+                            <img class="img-responsive model-img" src="{{img.photo.url}}">
+                        </a>
+                        {% endif %}
+                        {% endfor %}
+                    </div>
+                    <div class="col-md-6">
+                        <h3>{{ product.title|truncatechars:"20" }}</h3>
+                        <p>{{ product.description|truncatechars:"150"|linebreaks }}</p>
+                        <div class="thumbnail row-5">
+                            <div class="caption">
+                                <a href="{% url 'productsApp:productDetail' product.id %}" class="btn btn-primary" role="button">
+                                    查看详情
+                                </a>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                {% endfor %}
+
+                {% if pageData %}
+                <div class="paging">
+                    <ul id="pages" class="pagination pagination-sm pagination-xs">
+                        {% if pageData.first %}
+                        <li><a href="?page=1">1</a></li>
+                        {% endif %}
+                        {% if pageData.left %}
+                        {% if pageData.left_has_more %}
+                        <li><span>...</span></li>
+                        {% endif %}
+                        {% for i in pageData.left %}
+                        <li><a href="?page={{i}}">{{i}}</a></li>
+                        {% endfor %}
+                        {% endif %}
+                        <li class="active"><a href="?page={{pageData.page}}">{{pageData.page}}</a></li>
+                        {% if pageData.right %}
+                        {% for i in pageData.right %}
+                        <li><a href="?page={{i}}">{{i}}</a></li>
+                        {% endfor %}
+                        {% if pageData.right_has_more %}
+                        <li><span>...</span></li>
+                        {% endif %}
+                        {% endif %}
+                        {% if pageData.last %}
+                        <li><a href="?page={{pageData.total_pages}}">{{pageData.total_pages}}</a></li>
+                        {% endif %}
+                    </ul>
+                </div>
+                {% endif %}
+            </div>
+        </div>
+    </div>
+</div>
+{% endblock %}

+ 25 - 9
pythonweb/productsApp/views.py

@@ -3,16 +3,32 @@ from django.shortcuts import HttpResponse
 
 
 
 
 # Create your views here.
 # Create your views here.
-def robot(request):
-    html = '<html><body>家用机器人</body></html>'
-    return HttpResponse(html)
+# def robot(request):
+#     html = '<html><body>家用机器人</body></html>'
+#     return HttpResponse(html)
 
 
 
 
-def monitoring(request):
-    html = '<html><body>智能监控</body></html>'
-    return HttpResponse(html)
+# def monitoring(request):
+#     html = '<html><body>智能监控</body></html>'
+#     return HttpResponse(html)
 
 
 
 
-def face(request):
-    html = '<html><body>人脸识别解决方案</body></html>'
-    return HttpResponse(html)
+# def face(request):
+#     html = '<html><body>人脸识别解决方案</body></html>'
+#     return HttpResponse(html)
+
+def products(request,productName):
+    submenu=productName
+    if productName=='robot':
+        productName='家用机器人'
+    elif productName=='monitor':
+        productName='智能监控'
+    else:
+        productName='人脸识别解决方案'
+    return render(
+        request,'productList.html',{
+            'active_menu':'products',
+            'sub_menu':submenu,
+            "productName":productName,
+        }
+    )

+ 2 - 2
pythonweb/pythonweb/settings.py

@@ -112,9 +112,9 @@ AUTH_PASSWORD_VALIDATORS = [
 # Internationalization
 # Internationalization
 # https://docs.djangoproject.com/en/3.2/topics/i18n/
 # https://docs.djangoproject.com/en/3.2/topics/i18n/
 
 
-LANGUAGE_CODE = 'en-us'
+LANGUAGE_CODE = 'zh-Hans'
 
 
-TIME_ZONE = 'UTC'
+TIME_ZONE = 'Asia/Shanghai'
 
 
 USE_I18N = True
 USE_I18N = True
 
 

+ 5 - 0
pythonweb/pythonweb/urls.py

@@ -17,6 +17,8 @@ from django.contrib import admin
 from django.urls import path
 from django.urls import path
 from homeApp.views import home
 from homeApp.views import home
 from django.conf.urls import include
 from django.conf.urls import include
+from django.conf import settings
+from django.conf.urls.static import static
 
 
 urlpatterns = [
 urlpatterns = [
     path('admin/', admin.site.urls),
     path('admin/', admin.site.urls),
@@ -28,3 +30,6 @@ urlpatterns = [
     path('scienceApp/', include('scienceApp.urls')),    # 科研基地
     path('scienceApp/', include('scienceApp.urls')),    # 科研基地
     path('serviceApp/', include('serviceApp.urls')),    # 服务支持
     path('serviceApp/', include('serviceApp.urls')),    # 服务支持
 ]
 ]
+
+if settings.DEBUG:
+    urlpatterns += static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)