Skip to content

Commit

Permalink
day1 table
Browse files Browse the repository at this point in the history
  • Loading branch information
GriffithLin committed Apr 24, 2019
1 parent 7ecedce commit 012e1c7
Show file tree
Hide file tree
Showing 16 changed files with 87 additions and 4 deletions.
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>my_bbs</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
5 changes: 5 additions & 0 deletions .pydevproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
</pydev_project>
2 changes: 2 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding//blog/models.py=utf-8
Empty file added blog/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions blog/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions blog/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class BlogConfig(AppConfig):
name = 'blog'
Empty file added blog/migrations/__init__.py
Empty file.
44 changes: 44 additions & 0 deletions blog/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#coding:utf-8
from django.db import models
from django.contrib.auth.models import User
# Create your models here.

class Category(models.Model):
"""
Django 要求模型必须继承 models.Model 类。
Category 只需要一个简单的分类名 name 就可以了。
CharField 指定了分类名 name 的数据类型,CharField 是字符型,
CharField 的 max_length 参数指定其最大长度,超过这个长度的分类名就不能被存入数据库。
当然 Django 还为我们提供了多种其它的数据类型,如日期时间类型 DateTimeField、整数类型 IntegerField 等等。
Django 内置的全部类型可查看文档:
https://docs.djangoproject.com/en/1.10/ref/models/fields/#field-types
"""
name = models.CharField(max_length=100)

class Tag(models.Model):
"""
标签 Tag 也比较简单,和 Category 一样。
再次强调一定要继承 models.Model 类!
"""
name = models.CharField(max_length=100)

class Post(models.Model):
"""
文章的数据库表稍微复杂一点,主要是涉及的字段更多。
"""

#title
title = models.CharField(max_length=70)
body = models.TextField()
created_time = models.DateTimeField()
modified_time = models.DateTimeField()
#摘要 允许空
excerpt = models.CharField(max_length=200,blank=True)

category = models.ForeignKey(Category)
tags = models.ManyToManyField(Tag,blank=True)
# 文章作者,这里 User 是从 django.contrib.auth.models 导入的。
author = models.ForeignKey(User)



3 changes: 3 additions & 0 deletions blog/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions blog/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
Binary file added db.sqlite3
Binary file not shown.
Binary file added my_bbs/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added my_bbs/__pycache__/settings.cpython-37.pyc
Binary file not shown.
Binary file added my_bbs/__pycache__/urls.cpython-37.pyc
Binary file not shown.
Binary file added my_bbs/__pycache__/wsgi.cpython-37.pyc
Binary file not shown.
9 changes: 5 additions & 4 deletions my_bbs/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog',#注册blog应用
]

MIDDLEWARE = [
Expand Down Expand Up @@ -102,10 +103,10 @@

# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'
#django设置为中文
LANGUAGE_CODE = 'zh-hans'
#时区设置
TIME_ZONE = 'Asia/Shanghai'

USE_I18N = True

Expand Down

0 comments on commit 012e1c7

Please sign in to comment.