Merge pull request #303 from liangliangyy/dev

增加 DjangoBlog部署教程
且听风吟 7 years ago committed by GitHub
commit c52f343d20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,8 +19,7 @@ from django.conf import settings
from django.utils.feedgenerator import Rss201rev2Feed
from DjangoBlog.utils import CommonMarkdown
from django.contrib.auth import get_user_model
from django.contrib.auth.models import User
from DjangoBlog.utils import get_current_site
from datetime import datetime
class DjangoBlogFeed(Feed):
@ -46,8 +45,8 @@ class DjangoBlogFeed(Feed):
return CommonMarkdown.get_markdown(item.body)
def feed_copyright(self):
# print(get_current_site().name)
return "Copyright© 2018 且听风吟"
now = datetime.now()
return "Copyright© {year} 且听风吟".format(year=now.year)
def item_link(self, item):
return item.get_absolute_url()

@ -1,7 +1,7 @@
# DjangoBlog
🌍
*[English](README-en.md) ∙ [简体中文](README.md)*
*[English](/docs/README-en.md) ∙ [简体中文](README.md)*
基于`python3.6`和`Django2.1`的博客。
@ -46,7 +46,7 @@ mysql客户端从`pymysql`修改成了`mysqlclient`,具体请参考 [pypi](htt
`bin`目录是在`linux`环境中使用`Nginx`+`Gunicorn`+`virtualenv`+`supervisor`来部署的脚本和`Nginx`配置文件.可以参考我的文章:
>[使用Nginx+Gunicorn+virtualenv+supervisor来部署django项目](https://www.lylinux.org/%E4%BD%BF%E7%94%A8nginxgunicornvirtualenvsupervisor%E6%9D%A5%E9%83%A8%E7%BD%B2django%E9%A1%B9%E7%9B%AE.html)
>[DjangoBlog部署教程](https://www.lylinux.net/article/2019/8/5/58.html)
有详细的部署介绍.

@ -58,6 +58,6 @@ class BlogUserChangeForm(UserChangeForm):
class BlogUserAdmin(UserAdmin):
form = BlogUserChangeForm
add_form = BlogUserCreationForm
list_display = ('id', 'nickname', 'username', 'email', 'last_login', 'date_joined')
list_display = ('id', 'nickname', 'username', 'email', 'last_login', 'date_joined', 'source')
list_display_links = ('id', 'username')
ordering = ('-id',)

@ -11,9 +11,7 @@ class BlogUser(AbstractUser):
nickname = models.CharField('昵称', max_length=100, blank=True)
created_time = models.DateTimeField('创建时间', default=now)
last_mod_time = models.DateTimeField('修改时间', default=now)
source = models.CharField("创建涞源", max_length=100, blank=True)
# objects = BlogUserManager()
source = models.CharField("创建来源", max_length=100, blank=True)
def get_absolute_url(self):
return reverse('blog:author_detail', kwargs={'author_name': self.username})

@ -1,17 +1,8 @@
upstream hello_app_server {
server unix:/var/www/DjangoBlog/run/gunicorn.sock fail_timeout=0;
}
server {
server_name blog.lylinux.org;
root /var/www/DjangoBlog/;
listen 80;
keepalive_timeout 70;
access_log off;
location /static/ {
expires max;
@ -19,34 +10,14 @@ server {
}
location / {
# an HTTP header important enough to have its own Wikipedia entry:
# http://en.wikipedia.org/wiki/X-Forwarded-For
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# enable this if and only if you use HTTPS, this helps Rack
# set the proper protocol for doing redirects:
# proxy_set_header X-Forwarded-Proto https;
# pass the Host: header from the client right along so redirects
# can be set properly within the Rack application
proxy_set_header Host $http_host;
# we don't want nginx trying to do something clever with
# redirects, we set the Host: header above already.
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
# set "proxy_buffering off" *only* for Rainbows! when doing
# Comet/long-poll stuff. It's also safe to set if you're
# using only serving fast clients with Unicorn + nginx.
# Otherwise you _want_ nginx to buffer responses to slow
# clients, really.
# proxy_buffering off;
# Try to serve static files from nginx, no point in making an
# *application* server like Unicorn/Rainbows! serve static files.
if (!-f $request_filename) {
proxy_pass http://hello_app_server;
break;
proxy_pass http://127.0.0.1:8000;
break;
}
}

@ -1,7 +1,7 @@
#!/bin/bash
NAME="djangoblog" # Name of the application
DJANGODIR=//var/www/DjangoBlog # Django project directory
DJANGODIR=/var/www/DjangoBlog # Django project directory
SOCKFILE=/var/www/DjangoBlog/run/gunicorn.sock # we will communicte using this unix socket
USER=root # the user to run as
GROUP=root # the group to run as

@ -16,7 +16,7 @@ class Comment(models.Model):
is_enable = models.BooleanField('是否显示', default=True, blank=False, null=False)
class Meta:
ordering = ['-created_time']
ordering = ['-id']
verbose_name = "评论"
verbose_name_plural = verbose_name
get_latest_by = 'created_time'

@ -46,7 +46,7 @@ Files in `test` directory are for `travis` with automatic testing. You do not ne
In `bin` directory, we have scripts to deploy with `Nginx`+`Gunicorn`+`virtualenv`+`supervisor` on `linux` and `Nginx` configuration file. You can reference with my article
>[Using Nginx+Gunicorn+virtualenv+supervisor to deploy django project.](https://www.lylinux.org/%E4%BD%BF%E7%94%A8nginxgunicornvirtualenvsupervisor%E6%9D%A5%E9%83%A8%E7%BD%B2django%E9%A1%B9%E7%9B%AE.html)
>[DjangoBlog部署教程](https://www.lylinux.net/article/2019/8/5/58.html)
More deploy detail in this article.
Loading…
Cancel
Save