Step1:Use Python3 by virtualenv
reference :https://packaging.python.org/guides/installing-using-pip-and-virtualenv/
Updata the python and pip at the latest version
python3 -m pip install --user --upgrade pip
python3 -m pip --version
Install the virtualenv
python3 -m pip install --user virtualenv
Note:If you are using Python 3.3 or newer the venv
module is included in the Python standard library. This can also create and manage virtual environments, however, it only supports Python 3.
Creating a virtualenv
python3 -m virtualenv env
The second argument is the location to create the virtualenv. Generally, you can just create this in your project and call it env
.
virtualenv will create a virtual Python installation in the env
folder.
Activating a virtualenv
Before you can start installing or using packages in your virtualenv you’ll need to activate it. Activating a virtualenv will put the virtualenv-specific python
and pip
executables into your shell’s PATH
.
source env/bin/activate
Leaving the virtualenv
If you want to switch projects or otherwise leave your virtualenv, simply run:
deactivate
Step2: SET IDE
Install pycharm
Download and install: url:https://www.jetbrains.com/pycharm/download/#section=mac
chose the Professional version is enough & free
create a project and set python version
Notice:It`s better to use the python venv(virtual environment)
set the gitlab version manager
Notice:u can add the username:password before the url like this:
Step3:start a web subject
start subject and apps
>django-admin startproject mtools
>cd mtools;
>python manage.py starapp core;python manage.py starapp base;python manage.py starapp login
install mysql
package url:https://dev.mysql.com/downloads/mysql/8.0.html
star mysql on the manage table
config the settings
register the app into app_list
modify the databases info
use django ORM create tables
login/models
init the db and commit migrate
>python manage.py makemiagrations
>python manage.py migrate
register tables to admin
login/admin.py
from django.contrib import admin from login.models import Users # Register your models here. admin.site.register(Users)
create a super user
$ python manage.py createsuperuser Username (leave blank to use 'hubery'): hubery Email address: [email protected] Password: Password (again): Superuser created successfully.
config the urls
mtools/urls.py
running server
mtools/managers.py
login the admin web
=================
Step4: create the index web page
follow the django MTV construct
M:models
T:templates
V:views
login/models:
login/views:
templates/index.html
restart the server