首先根据已有网站(http://dig.chouti.com/)信息进行创建数据库并创建表
#_*_ coding:utf-8 _*_ from django.db import models
Create your models here.
#chouti.com
class Usertype(models.Model):
display =models.CharField(max_length=50)def __unicode__(self): return self.display
class 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.display
class 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样式的方法