ITPub博客

首页 > IT职业 > IT职场 > python django整理(三)页面基础(仿BBS)

python django整理(三)页面基础(仿BBS)

IT职场 作者:renke 时间:2021-09-09 09:30:22 0 删除 编辑

首先根据已有网站(http://dig.chouti.com/)信息进行创建数据库并创建表

#_*_ coding:utf-8 _*_from django.db import models# Create your models here.#chouti.comclass Usertype(models.Model):
    display =models.CharField(max_length=50)    def __unicode__(self):
        return  self.displayclass Admin(models.Model):
    username=models.CharField(max_length=50)
    password=models.CharField(max_length=256)
    email=models.EmailField()
    user_type=models.ForeignKey("Usertype")    def __unicode__(self):
        return  self.username#交互#class chat(models.Model):class NewsType(models.Model):
    display=models.CharField(max_length=50)    def __unicode__(self):
        return self.displayclass News(models.Model):
    title=models.CharField(max_length=50)
    sunmmary=models.CharField(max_length=50)
    url=models.CharField(max_length=50)   #跳转连接
    favor_count=models.CharField(default=0,max_length=50)   #点赞
    reply_count=models.CharField(default=0,max_length=50)  #回复
    news_type=models.ForeignKey('NewsType')
    user=models.ForeignKey('Admin')
    create_data=models.DateTimeField(auto_now_add= True)    def __unicode__(self):
        return self.displayclass Reply(models.Model):
    content=models.TextField()
    user=models.ForeignKey('Admin')
    new=models.ForeignKey('News')
    create_data=models.DateTimeField(auto_now_add=True)    def __unicode__(self):
        return self.content

接着创建static与template(对于这两个文件注意修改默认的路径,后面的截图中我虽然实现了,但是路径是有点问题的)

图片描述
获取CSS样式的方法
图片描述


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/430/viewspace-2803974/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: SqlHelper和DBHelper
请登录后发表评论 登录
全部评论

注册时间:2019-10-11

  • 博文量
    140
  • 访问量
    17929