diff --git a/.project b/.project new file mode 100644 index 0000000..95b086c --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + my_bbs + + + + + + org.python.pydev.PyDevBuilder + + + + + + org.python.pydev.pythonNature + + diff --git a/.pydevproject b/.pydevproject new file mode 100644 index 0000000..d001f0a --- /dev/null +++ b/.pydevproject @@ -0,0 +1,5 @@ + + +Default +python interpreter + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..e7316b8 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding//blog/models.py=utf-8 diff --git a/blog/__init__.py b/blog/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/blog/admin.py b/blog/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/blog/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/blog/apps.py b/blog/apps.py new file mode 100644 index 0000000..7930587 --- /dev/null +++ b/blog/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class BlogConfig(AppConfig): + name = 'blog' diff --git a/blog/migrations/__init__.py b/blog/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/blog/models.py b/blog/models.py new file mode 100644 index 0000000..496e30e --- /dev/null +++ b/blog/models.py @@ -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) + + + \ No newline at end of file diff --git a/blog/tests.py b/blog/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/blog/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/blog/views.py b/blog/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/blog/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000..5a0aa84 Binary files /dev/null and b/db.sqlite3 differ diff --git a/my_bbs/__pycache__/__init__.cpython-37.pyc b/my_bbs/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..d6caf46 Binary files /dev/null and b/my_bbs/__pycache__/__init__.cpython-37.pyc differ diff --git a/my_bbs/__pycache__/settings.cpython-37.pyc b/my_bbs/__pycache__/settings.cpython-37.pyc new file mode 100644 index 0000000..96f39a3 Binary files /dev/null and b/my_bbs/__pycache__/settings.cpython-37.pyc differ diff --git a/my_bbs/__pycache__/urls.cpython-37.pyc b/my_bbs/__pycache__/urls.cpython-37.pyc new file mode 100644 index 0000000..b59ef7d Binary files /dev/null and b/my_bbs/__pycache__/urls.cpython-37.pyc differ diff --git a/my_bbs/__pycache__/wsgi.cpython-37.pyc b/my_bbs/__pycache__/wsgi.cpython-37.pyc new file mode 100644 index 0000000..830e505 Binary files /dev/null and b/my_bbs/__pycache__/wsgi.cpython-37.pyc differ diff --git a/my_bbs/settings.py b/my_bbs/settings.py index 5e1cca3..50d4081 100644 --- a/my_bbs/settings.py +++ b/my_bbs/settings.py @@ -37,6 +37,7 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'blog',#注册blog应用 ] MIDDLEWARE = [ @@ -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