diff --git a/README.md b/README.md index 0a95bec..c1c98db 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,20 @@ -## Django搭建博客 -![py27](https://camo.githubusercontent.com/392a32588691a8418368a51ff33a12d41f11f0a9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f707974686f6e2d322e372d6666363962342e737667) -  [![](https://img.shields.io/badge/Django-1.10-green.svg)](http://www.spiderpy.cn/blog/) -[![](https://img.shields.io/badge/Powered%20by-@j_hao104-blue.svg)](http://www.spiderpy.cn/blog/) +## Django搭建个人博客 +![py3.6](https://img.shields.io/badge/python-3.6-brightgreen.svg) +  [![](https://img.shields.io/badge/django-2.0-brightgreen.svg)]() +[![](https://img.shields.io/badge/Powered%20by-@问道编程-blue.svg)](http://www.cnblogs.com/wendaobiancheng/) 使用Django快速搭建博客 -### 要求 -* Python: 2.X -* Django: 1.10.x -* Mysql +### 环境 +* Python: 3.X +* Django: 2.0.x +* MySQL -### 示例博客: +### 示例博客: ### 特点 -* 博客文章 markdown 渲染,代码高亮 -* 三方社会化评论系统支持(畅言) +* 博客文章 `markdown` 渲染,代码高亮 +* 第三方社会化评论系统支持(畅言) * 三种皮肤自由切换 * 阅读排行榜/最新评论 * 多目标源博文分享 @@ -23,9 +23,7 @@ ### 下载 ``` -wget https://github.com/jhao104/django-blog/archive/master.zip -or -git clone git@github.com:jhao104/django-blog.git +git clone https://github.com/myminwang/myblog.git ``` ### 安装 @@ -33,7 +31,7 @@ git clone git@github.com:jhao104/django-blog.git pip install -r requirements.txt #安装所有依赖 setting.py配置自己的数据库 配置畅言:到http://changyan.kuaizhan.com/注册站点,将templates/message.html中js部分换成你在畅言中生成的js。 -python manage.py makemigrations blog +python manage.py makemigrations python manage.py migrate python manage.py runserver ``` @@ -50,7 +48,3 @@ python manage.py runserver * 文章内容 ![文章内容](./doc/image/image3.png) - -## 历史版本 - -* [黑白简约版](https://github.com/jhao104/django-blog/tree/v1.0) diff --git a/blog/__pycache__/views.cpython-36.pyc b/blog/__pycache__/views.cpython-36.pyc index 94d82ea..db2a18b 100644 Binary files a/blog/__pycache__/views.cpython-36.pyc and b/blog/__pycache__/views.cpython-36.pyc differ diff --git a/blog/views.py b/blog/views.py index 3260818..a0eb359 100644 --- a/blog/views.py +++ b/blog/views.py @@ -188,3 +188,25 @@ class Tagcloud(View): 'comment_list': comment_list, 'count': count, }) + + +def page_not_look(request): + """全局403配置""" + from django.shortcuts import render_to_response + response = render_to_response('403.html',{}) + response.status_code = 403 + return response + +def page_not_found(request): + """全局404配置""" + from django.shortcuts import render_to_response + response = render_to_response('404.html',{}) + response.status_code = 404 + return response + +def page_error(request): + """全局500配置""" + from django.shortcuts import render_to_response + response = render_to_response('500.html',{}) + response.status_code = 500 + return response \ No newline at end of file diff --git a/doc/image/image1.png b/doc/image/image1.png new file mode 100755 index 0000000..49c1319 Binary files /dev/null and b/doc/image/image1.png differ diff --git a/doc/image/image2.png b/doc/image/image2.png new file mode 100755 index 0000000..689d9a4 Binary files /dev/null and b/doc/image/image2.png differ diff --git a/doc/image/image3.png b/doc/image/image3.png new file mode 100755 index 0000000..e8d8ad5 Binary files /dev/null and b/doc/image/image3.png differ diff --git a/myblog/__pycache__/settings.cpython-36.pyc b/myblog/__pycache__/settings.cpython-36.pyc index 598bc69..bb0bdac 100644 Binary files a/myblog/__pycache__/settings.cpython-36.pyc and b/myblog/__pycache__/settings.cpython-36.pyc differ diff --git a/myblog/__pycache__/urls.cpython-36.pyc b/myblog/__pycache__/urls.cpython-36.pyc index aac7559..c05a672 100644 Binary files a/myblog/__pycache__/urls.cpython-36.pyc and b/myblog/__pycache__/urls.cpython-36.pyc differ diff --git a/myblog/settings.py b/myblog/settings.py index 9aff6e1..e3bae53 100644 --- a/myblog/settings.py +++ b/myblog/settings.py @@ -30,7 +30,7 @@ SECRET_KEY = '%oyd37a)%mh0@zts7b)ki5f1u(ibiw9z%6w9-khmz^gvrd+3&2' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ['*'] # Application definition diff --git a/myblog/urls.py b/myblog/urls.py index 2acfabc..fd20df1 100644 --- a/myblog/urls.py +++ b/myblog/urls.py @@ -34,3 +34,9 @@ if settings.DEBUG: # 配置静态文件访问处理 urlpatterns.append(url(r'^media/(?P.*)$', serve, {'document_root': settings.MEDIA_ROOT})) urlpatterns.append(url(r'^static/(?P.*)$', serve, {'document_root': settings.STATIC_ROOT})) + + +# 全局页面配置 +handler403 = 'blog.views.page_not_look' +handler404 = 'blog.views.page_not_found' +handler500 = 'blog.views.page_error' diff --git a/static/images/403.jpeg b/static/images/403.jpeg new file mode 100644 index 0000000..71bf597 Binary files /dev/null and b/static/images/403.jpeg differ diff --git a/static/images/404.jpg b/static/images/404.jpg new file mode 100644 index 0000000..66c453b Binary files /dev/null and b/static/images/404.jpg differ diff --git a/static/images/500.png b/static/images/500.png new file mode 100644 index 0000000..2189584 Binary files /dev/null and b/static/images/500.png differ diff --git a/templates/403.html b/templates/403.html new file mode 100755 index 0000000..9508c84 --- /dev/null +++ b/templates/403.html @@ -0,0 +1,10 @@ + + + + + 403 + + + + + diff --git a/templates/404.html b/templates/404.html new file mode 100755 index 0000000..67078e7 --- /dev/null +++ b/templates/404.html @@ -0,0 +1,10 @@ + + + + + 404 + + + + + diff --git a/templates/500.html b/templates/500.html new file mode 100644 index 0000000..9900f6a --- /dev/null +++ b/templates/500.html @@ -0,0 +1,10 @@ + + + + + 500 + + + + + \ No newline at end of file