前言

这篇博客针对《Python+Django+MongoDB数据库网站网页实例》编写代码,代码整洁,规则,易读。 学习与应用推荐首选。


运行结果

MongoDB数据库网站网页实例-编程语言Python+Django-LMLPHP

文章目录

一、所需工具软件
二、使用步骤
       1. 主要代码
       2. 运行结果
三、在线协助

一、所需工具软件

       1. Python, Django
       2. MongoDB数据库

二、使用步骤

代码如下(示例):
model.py
class Article(models.Model):
    title = models.CharField(u'标题', max_length=256)
    content = models.TextField(u'内容', null=True)

    pub_date = models.DateTimeField(u'发表时间', auto_now_add=True, editable=True, null=True)
    update_time = models.DateTimeField(u'更新时间', auto_now=True, null=True)

    def __str__(self):  # 在Python3中用 __str__ 代替 __unicode__
        return self.title

admin.py
class ArticleAdmin(admin.ModelAdmin):
    list_display = ('title', 'content', 'pub_date', 'update_time',)
    #list_display = ('title',)

from django.shortcuts import render

# Create your views here.

#coding:utf8
from django.shortcuts import render
from django.http import HttpResponse

view.py
# Create your views here.
def index(request):
    #return HttpResponse("hello")
    return render(request, 'blog/index.html')

运行结果
MongoDB数据库网站网页实例-编程语言Python+Django-LMLPHP MongoDB数据库网站网页实例-编程语言Python+Django-LMLPHP

三、在线协助:

如需安装运行环境或远程调试,见文章底部个人 QQ 名片,由专业技术人员远程协助!

当前文章连接:https://blog.csdn.net/alicema1111/article/details/132666851
个人博客主页https://blog.csdn.net/alicema1111?type=blog
博主所有文章点这里:https://blog.csdn.net/alicema1111?type=blog

博主推荐:
Python人脸识别考勤打卡系统:
https://blog.csdn.net/alicema1111/article/details/133434445
Python果树水果识别https://blog.csdn.net/alicema1111/article/details/130862842
Python+Yolov8+Deepsort入口人流量统计:https://blog.csdn.net/alicema1111/article/details/130454430
Python+Qt人脸识别门禁管理系统:https://blog.csdn.net/alicema1111/article/details/130353433
Python+Qt指纹录入识别考勤系统:https://blog.csdn.net/alicema1111/article/details/129338432
Python Yolov5火焰烟雾识别源码分享:https://blog.csdn.net/alicema1111/article/details/128420453
Python+Yolov8路面桥梁墙体裂缝识别:https://blog.csdn.net/alicema1111/article/details/133434445

10-05 14:56