This is a very simple dajngo blog app. Only appropriate for linux OS Django version: 1.10.4 OS: Centos 7.0 Python: 2.7 Requires: pip install django-tinymce uwsgi pymysql django-ratelimit-backend
- Clone the codes to your linux:
# git clone [email protected]:lufy90/Blog
- Edit the setting.py about the host address, change
ALLOWD_HOSTS
to your address:
# vim blog/setting.py
ALLOWED_HOSTS = [u'192.168.10.10']
- Create database, default make a sqlite3 database at app root dir.
./manage.py migrate
Some times this only creates the application admin tables, tables of home
will not be created. This could be solved by:
./manage.py makemigrations
./manage.py migrate
- Then you can run the server within Blog directory:
# ./manager runserver 0.0.0.0:8000
- Create super user
# ./manager.py createsuperuser
- Change user password
# ./manager.py changepassword
The former trying steps are just for preview. If you're willing to make it run as a real blog, then do the next steps:
- touch mysql config file:
# cat /etc/my-blog.cnf
[client]
database = <dbname>
user = <dbuser>
password = <dbpassword>
default-character-set = utf8
-
Edit
blog/setting
, set theDATABASES
to be usingdb_mysql
:DATABASES = db_mysql
-
Then run:
#./start.sh
If you have the right firewall and network configuration, now the site can be visited from browser: http://192.168.10.10:8000
# cat blog.conf
upstream django {
server unix:///home/Blog/socket/blog.sock;
}
server {
listen 80;
server_name blog.com;
charset utf-8;
client_max_body_size 75M;
location /static {
alias /home/Blog/home/static;
}
location / {
uwsgi_pass django;
include /home/Blog/blog/uwsgi_params;
}
}
# cat /etc/blog.cnf
[client]
database = <dbname>
user = <dbuser>
password = <dbpassword>
default-character-set = utf8
20190727 Do more limitations on making comments
- Text length
- Key words filter, with customised validation in /home/models.py
20191008 Change model.py for adapting python3.6 and django 2.2.6, on centos 8 Change pymsyql to mysqlclient, for resolving the following issue: ISSUE: django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3. Changed files on host lufy.org:
- blog/init.py -- about pymysql
- home/models.py -- about foreign keys