Python Getting Started to Practice - Djando for Beginners


Installation and initialization

Installing django is actually quite simple, open the command line terminal tool and execute

pip3 install django

For more information about django please follow [official website content](https://www.djangoproject.com/)

Once installed, you need to verify that the installation was successful, which can be done as follows.

After verifying it, move on to the next side and go build a Djando project to get over it. In the command line, type

$ cd djando # Go to a file home that you created (the folder I went into here is named django, you name it whatever you want)

$ django-admin startproject webapp # Create awebapp Job Catalog

$ cd webapp # Once created go intowebapp table of contents

$ py manage.py runserver # Enter the command to run a Django project to see

Performing system checks...

System check identified no issues (0 silenced).

December 08, 2017 - 14:25:06

Django version 1.11.6, using settings 'webapp.settings'

Starting development server at http://127.0.0.1:8000/

Quit the server with CONTROL-C.

After executing the command, access via browser.

http://127.0.0.1:8000/

The results are as follows

databases

I've just initialized the webapp project I created and run it to see the results, now let's compile the database needed

Go to the project directory and execute the command to compile the database

$ cd webapp

$ py manage.py makemigrations

reimplementation

$ py manage.py migrate

Operations to perform:

Apply all migrations: admin, auth, contenttypes, sessions

Running migrations:

Applying contenttypes.0001_initial... OK

Applying auth.0001_initial... OK

Applying admin.0001_initial... OK

Applying admin.0002_logentry_remove_auto_add... OK

Applying contenttypes.0002_remove_content_type_name... OK

Applying auth.0002_alter_permission_name_max_length... OK

Applying auth.0003_alter_user_email_max_length... OK

Applying auth.0004_alter_user_username_opts... OK

Applying auth.0005_alter_user_last_login_null... OK

Applying auth.0006_require_contenttypes_0002... OK

Applying auth.0007_alter_validators_add_error_messages... OK

Applying auth.0008_alter_user_username_max_length... OK

Applying sessions.0001_initial... OK

Note: This command basically means to create a database for our project webapp, where makemigrations compiles the database file and migrate gives effect to the compiled database file

If you follow the above command as I output, you have created the database file successfully

To verify and see the results together.

py manage.py runserver

Preview http://127.0.0.1:8000/admin after executing the command

After the backend login screen can be previewed we have to create a username and password to login to the backend

Go to the project folder

$ cd webapp

Execution of orders

$ py manage.py createsuperuser

Enter the login you need to create Username

Username (leave blank to use 'fjun'): fjun

Enter the email address you need to use

Email address: 921516@qq.com

Enter the login password you need to create

Password:

Password to confirm login

Password (again):

Prompt created successfully

Superuser created successfully.

Once created

Running items

$ py manage.py runserver

Open your browser and type

http://127.0.0.1:8000/admin

How you just created a username and password to see the following screen indicates successful access to the backend

Those who come meet in person, those who go forget in the jungle.

complete


Recommended>>
1、Data Structures Lists
2、Big positive for ETH Is it reliable that ethereum is going to overtake bitcoin in market cap
3、Web Performance Optimization
4、When will the car driving license test be abolished
5、How about Geely Links design check out its neural network wiring harness design

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号