Skip to content

Commit bd8ca91

Browse files
committed
update README
1 parent 2e66cb1 commit bd8ca91

File tree

16 files changed

+72
-20
lines changed

16 files changed

+72
-20
lines changed

README.md

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
## Django搭建博客
2-
![py27](https://camo.githubusercontent.com/392a32588691a8418368a51ff33a12d41f11f0a9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f707974686f6e2d322e372d6666363962342e737667)
3-
 [![](https://img.shields.io/badge/Django-1.10-green.svg)](http://www.spiderpy.cn/blog/)
4-
[![](https://img.shields.io/badge/Powered%20by-@j_hao104-blue.svg)](http://www.spiderpy.cn/blog/)
1+
## Django搭建个人博客
2+
![py3.6](https://img.shields.io/badge/python-3.6-brightgreen.svg)
3+
 [![](https://img.shields.io/badge/django-2.0-brightgreen.svg)]()
4+
[![](https://img.shields.io/badge/Powered%20by-@问道编程-blue.svg)](http://www.cnblogs.com/wendaobiancheng/)
55

66
使用Django快速搭建博客
7-
### 要求
8-
* Python: 2.X
9-
* Django: 1.10.x
10-
* Mysql
7+
### 环境
8+
* Python: 3.X
9+
* Django: 2.0.x
10+
* MySQL
1111

12-
### 示例博客:<http://www.spiderpy.cn/blog>
12+
### 示例博客:<http://www.mylanbitou.top>
1313

1414
### 特点
1515

16-
* 博客文章 markdown 渲染,代码高亮
17-
* 三方社会化评论系统支持(畅言)
16+
* 博客文章 `markdown` 渲染,代码高亮
17+
* 第三方社会化评论系统支持(畅言)
1818
* 三种皮肤自由切换
1919
* 阅读排行榜/最新评论
2020
* 多目标源博文分享
@@ -23,17 +23,15 @@
2323

2424
### 下载
2525
```
26-
wget https://github.com/jhao104/django-blog/archive/master.zip
27-
or
28-
git clone [email protected]:jhao104/django-blog.git
26+
git clone https://github.com/myminwang/myblog.git
2927
```
3028

3129
### 安装
3230
```
3331
pip install -r requirements.txt #安装所有依赖
3432
setting.py配置自己的数据库
3533
配置畅言:到http://changyan.kuaizhan.com/注册站点,将templates/message.html中js部分换成你在畅言中生成的js。
36-
python manage.py makemigrations blog
34+
python manage.py makemigrations
3735
python manage.py migrate
3836
python manage.py runserver
3937
```
@@ -50,7 +48,3 @@ python manage.py runserver
5048

5149
* 文章内容
5250
![文章内容](./doc/image/image3.png)
53-
54-
## 历史版本
55-
56-
* [黑白简约版](https://github.com/jhao104/django-blog/tree/v1.0)

blog/__pycache__/views.cpython-36.pyc

650 Bytes
Binary file not shown.

blog/views.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,25 @@ def get(self, request, id):
188188
'comment_list': comment_list,
189189
'count': count,
190190
})
191+
192+
193+
def page_not_look(request):
194+
"""全局403配置"""
195+
from django.shortcuts import render_to_response
196+
response = render_to_response('403.html',{})
197+
response.status_code = 403
198+
return response
199+
200+
def page_not_found(request):
201+
"""全局404配置"""
202+
from django.shortcuts import render_to_response
203+
response = render_to_response('404.html',{})
204+
response.status_code = 404
205+
return response
206+
207+
def page_error(request):
208+
"""全局500配置"""
209+
from django.shortcuts import render_to_response
210+
response = render_to_response('500.html',{})
211+
response.status_code = 500
212+
return response

doc/image/image1.png

1.32 MB
Loading

doc/image/image2.png

684 KB
Loading

doc/image/image3.png

2.75 MB
Loading
5 Bytes
Binary file not shown.
130 Bytes
Binary file not shown.

myblog/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# SECURITY WARNING: don't run with debug turned on in production!
3131
DEBUG = True
3232

33-
ALLOWED_HOSTS = []
33+
ALLOWED_HOSTS = ['*']
3434

3535

3636
# Application definition

myblog/urls.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,9 @@
3434
# 配置静态文件访问处理
3535
urlpatterns.append(url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}))
3636
urlpatterns.append(url(r'^static/(?P<path>.*)$', serve, {'document_root': settings.STATIC_ROOT}))
37+
38+
39+
# 全局页面配置
40+
handler403 = 'blog.views.page_not_look'
41+
handler404 = 'blog.views.page_not_found'
42+
handler500 = 'blog.views.page_error'

static/images/403.jpeg

32.4 KB
Loading

static/images/404.jpg

120 KB
Loading

static/images/500.png

33.7 KB
Loading

templates/403.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>403</title>
6+
</head>
7+
<body >
8+
<img src="../static/images/403.jpeg" alt="">
9+
</body>
10+
</html>

templates/404.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>404</title>
6+
</head>
7+
<body >
8+
<img src="../static/images/404.jpg" alt="">
9+
</body>
10+
</html>

templates/500.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>500</title>
6+
</head>
7+
<body >
8+
<img src="../static/images/500.png" alt="">
9+
</body>
10+
</html>

0 commit comments

Comments
 (0)