A Web project based on Django, used for Web programming and Web API testing practice.
Installed apps:
- sign
python3 manage.py runserverorpython3 manage.py runserver 127.0.0.1:8001to launch the site.python3 manage.py shellto enable Django shell console
sudo apt-get install mysql-server,sudo apt isntall mysql-client,sudo apt install libmysqlclient-dev.- Use
sudo netstat -tap | grep mysqlto check whether mysql is running, open mysql console usingmysql -uroot -p. - To enable remote-access,
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnfand comment the line ofbind-address = 127.0.0.1. - Open mysql console again, execute
grant all on *.* to root@'%' identified by 'ROOT-PASSWORD' with grant option;andflush privileges;. - Quit mysql console and restart mysql service by
service mysql restart.
- Mysql service is required, IP address, user name and password need be configured in guest/settings.py as part of DATABASES configuraiton.
mysql> create database guest character set utf8;to init guest database in Mysql at very beiginning.python3 manage.py createsuperuserto create super user account.
- To support interface API test and avoid
CSRF varification failederror, the line ofdjango.middleware.csrf.CsrfViewMiddlewareof MIDDLEWARE insettings.pyis disabled. - Django rest framework is imported to implement interface API, try this(with HTTPie):
C:\Users\admin>http -a admin:admin01234 http://127.0.0.1:8000/rest/
HTTP/1.1 200 OK
Allow: GET, HEAD, OPTIONS
Content-Length: 183
Content-Type: application/json
Date: Tue, 26 Jun 2018 09:01:51 GMT
Server: WSGIServer/0.2 CPython/3.6.4
Vary: Accept, Cookie
X-Frame-Options: SAMEORIGIN
{
"events": "http://127.0.0.1:8000/rest/events/",
"groups": "http://127.0.0.1:8000/rest/groups/",
"guests": "http://127.0.0.1:8000/rest/guests/",
"users": "http://127.0.0.1:8000/rest/users/"
}