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

mex-env

 

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)

 

mex-env

set the gitlab version manager

Notice:u can add the username:password  before the url  like this:


mex-env

 

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


mex-env

 

install mysql 

package url:https://dev.mysql.com/downloads/mysql/8.0.html
mex-env

 

star mysql on the manage table
mex-env

config the settings

register the app into app_listmex-env

 

modify the databases info


mex-env

 

use django ORM create tables

login/models


mex-env

 

init the db and commit  migrate

 

>python manage.py makemiagrations

>python manage.py migrate
mex-env

 

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

mex-env

 

running server

mtools/managers.py

mex-env

login the admin web

mex-env

=================

Step4: create the index web page

follow the django MTV construct 

M:models

T:templates

V:views

mex-env

login/models:


mex-env

login/views:


mex-env

templates/index.html


mex-env

restart the server


mex-env

 

相关文章: