From 33977575255bc6d7fb35dd35a1152bd6ed80d6bb Mon Sep 17 00:00:00 2001 From: liangliangyy Date: Thu, 13 Jun 2019 21:22:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9mysql=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E4=B8=BAmysqlclient,=E5=A2=9E=E5=8A=A0issue=E6=A8=A1?= =?UTF-8?q?=E7=89=88,fix=20#227?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE.md | 18 ++++++++++++++++++ .travis.yml | 1 + DjangoBlog/__init__.py | 2 -- README.md | 2 ++ blog/models.py | 12 +++--------- requirements.txt | 30 ++++++++++++++++-------------- travis_test/__init__.py | 2 -- travis_test/requirements.txt | 30 ++++++++++++++++-------------- 8 files changed, 56 insertions(+), 41 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..2b5b7aa --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,18 @@ + + +**我确定我已经查看了** (标注`[ ]`为`[x]`) + +- [ ] [DjangoBlog的readme](https://github.com/liangliangyy/DjangoBlog/blob/master/README.md) +- [ ] [配置说明](https://github.com/liangliangyy/DjangoBlog/blob/master/bin/config.md) +- [ ] [其他 Issues](https://github.com/liangliangyy/DjangoBlog/issues) + +---- + +**我要申请** (标注`[ ]`为`[x]`) + +- [ ] BUG 反馈 +- [ ] 添加新的特性或者功能 +- [ ] 请求技术支持 diff --git a/.travis.yml b/.travis.yml index 5c4c275..a3a725f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ branches: - master # command to install dependencies install: + - apt-get install python3-dev default-libmysqlclient-dev - pip install -r travis_test/requirements.txt - pip install python-coveralls - pip install coverage codecov diff --git a/DjangoBlog/__init__.py b/DjangoBlog/__init__.py index c45523b..e69de29 100644 --- a/DjangoBlog/__init__.py +++ b/DjangoBlog/__init__.py @@ -1,2 +0,0 @@ -import pymysql -pymysql.install_as_MySQLdb() \ No newline at end of file diff --git a/README.md b/README.md index 4a32b3f..6b65a15 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ - 网站异常邮件提醒,若有未捕捉到的异常会自动发送提醒邮件。 - 集成了微信公众号功能,现在可以使用微信公众号来管理你的vps了。 ## 安装 +mysql客户端从`pymysql`修改成了`mysqlclient`,具体请参考 [pypi](https://pypi.org/project/mysqlclient/) 查看安装前的准备。 + 使用pip安装: `pip install -Ur requirements.txt` diff --git a/blog/models.py b/blog/models.py index 4c8b7df..920f0b0 100644 --- a/blog/models.py +++ b/blog/models.py @@ -30,21 +30,15 @@ class BaseModel(models.Model): last_mod_time = models.DateTimeField('修改时间', default=now) def save(self, *args, **kwargs): - - if not isinstance(self, Article) and 'slug' in self.__dict__: - if getattr(self, 'slug') == 'no-slug' or not self.id: - slug = getattr(self, 'title') if 'title' in self.__dict__ else getattr(self, 'name') - setattr(self, 'slug', slugify(slug)) is_update_views = isinstance(self, Article) and 'update_fields' in kwargs and kwargs['update_fields'] == [ 'views'] if is_update_views: Article.objects.filter(pk=self.pk).update(views=self.views) else: + if 'slug' in self.__dict__: + slug = getattr(self, 'title') if 'title' in self.__dict__ else getattr(self, 'name') + setattr(self, 'slug', slugify(slug)) super().save(*args, **kwargs) - # is_update_views = 'update_fields' in kwargs and len(kwargs['update_fields']) == 1 and kwargs['update_fields'][ - # 0] == 'views' - # from DjangoBlog.blog_signals import article_save_signal - # article_save_signal.send(sender=self.__class__, is_update_views=is_update_views, id=self.id) def get_full_url(self): site = get_current_site().domain diff --git a/requirements.txt b/requirements.txt index 5b7b7f8..e29c139 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,53 +3,55 @@ asn1crypto==0.24.0 astroid==2.2.5 bottle==0.12.16 certifi==2019.3.9 -cffi==1.12.2 +cffi==1.12.3 chardet==3.0.4 coverage==4.5.3 cryptography==2.6.1 -Django==2.1.7 +Django==2.2.1 django-appconf==1.0.3 django-autoslug==1.9.4 django-compressor==2.2 django-debug-toolbar==1.11 django-haystack==2.8.1 django-ipware==2.1.0 -django-mdeditor==0.1.13 +django-mdeditor==0.1.14 django-uuslug==1.1.8 elasticsearch==7.0.0 elasticsearch-dsl==7.0.0 idna==2.8 ipaddress==1.0.22 -isort==4.3.15 +isort==4.3.20 jieba==0.39 jsonpickle==1.1 -lazy-object-proxy==1.3.1 +lazy-object-proxy==1.4.1 markdown2==2.3.7 mccabe==0.6.1 mistune==0.8.4 +mysqlclient==1.4.2.post1 olefile==0.46 packaging==19.0 -Pillow==5.4.1 +Pillow==6.0.0 pycparser==2.19 -Pygments==2.3.1 +Pygments==2.4.0 pylint==2.3.1 -PyMySQL==0.9.3 -pyparsing==2.3.1 +pyparsing==2.4.0 python-dateutil==2.8.0 python-logstash==0.4.6 python-memcached==1.59 -python-slugify==3.0.0 -pytz==2018.9 +python-slugify==3.0.2 +pytz==2019.1 raven==6.10.0 -requests==2.21.0 +rcssmin==1.0.6 +requests==2.22.0 +rjsmin==1.1.0 six==1.12.0 sqlparse==0.3.0 text-unidecode==1.2 typed-ast==1.3.1 Unidecode==1.0.23 -urllib3==1.24.2 +urllib3==1.25.2 webencodings==0.5.1 -WeRoBot==1.8.0 +WeRoBot==1.9.0 Whoosh==2.7.4 wrapt==1.11.1 xmltodict==0.12.0 diff --git a/travis_test/__init__.py b/travis_test/__init__.py index c45523b..e69de29 100644 --- a/travis_test/__init__.py +++ b/travis_test/__init__.py @@ -1,2 +0,0 @@ -import pymysql -pymysql.install_as_MySQLdb() \ No newline at end of file diff --git a/travis_test/requirements.txt b/travis_test/requirements.txt index aa6d898..c5456a0 100644 --- a/travis_test/requirements.txt +++ b/travis_test/requirements.txt @@ -3,52 +3,54 @@ asn1crypto==0.24.0 astroid==2.2.5 bottle==0.12.16 certifi==2019.3.9 -cffi==1.12.2 +cffi==1.12.3 chardet==3.0.4 coverage==4.5.3 cryptography==2.6.1 -Django==2.1.7 +Django==2.2.1 django-appconf==1.0.3 django-autoslug==1.9.4 django-compressor==2.2 django-debug-toolbar==1.11 django-haystack==2.8.1 django-ipware==2.1.0 -django-mdeditor==0.1.13 +django-mdeditor==0.1.14 django-uuslug==1.1.8 elasticsearch==7.0.0 elasticsearch-dsl==7.0.0 idna==2.8 ipaddress==1.0.22 -isort==4.3.15 +isort==4.3.20 jieba==0.39 jsonpickle==1.1 -lazy-object-proxy==1.3.1 +lazy-object-proxy==1.4.1 markdown2==2.3.7 mccabe==0.6.1 mistune==0.8.4 +mysqlclient==1.4.2.post1 olefile==0.46 packaging==19.0 -Pillow==5.4.1 +Pillow==6.0.0 pycparser==2.19 -Pygments==2.3.1 +Pygments==2.4.0 pylint==2.3.1 -PyMySQL==0.9.3 -pyparsing==2.3.1 +pyparsing==2.4.0 python-dateutil==2.8.0 python-logstash==0.4.6 -python-slugify==3.0.0 -pytz==2018.9 +python-slugify==3.0.2 +pytz==2019.1 raven==6.10.0 -requests==2.21.0 +rcssmin==1.0.6 +requests==2.22.0 +rjsmin==1.1.0 six==1.12.0 sqlparse==0.3.0 text-unidecode==1.2 typed-ast==1.3.1 Unidecode==1.0.23 -urllib3==1.24.2 +urllib3==1.25.2 webencodings==0.5.1 -WeRoBot==1.8.0 +WeRoBot==1.9.0 Whoosh==2.7.4 wrapt==1.11.1 xmltodict==0.12.0