Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A tutorial on the method of making a classic website in Django

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "the method tutorial of making a classic website in the actual combat of Django website". In the daily operation, I believe that many people have doubts on the method tutorial of making a classic website in the actual combat of Django website. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "the method tutorial of making a classic website in Django website". Next, please follow the editor to study!

I. Preface

Features include login, registration, logout, encryption, secret-free login, and forgetting passwords, so let's get started.

Create a project and create a sub-application

First create the project, and then create the sub-application under the project root, as follows:

Django-admin startproject demo # create project python manage.py startapp web # create sub-application

III. Configuration

Go to the project directory, and open settings.py to make the appropriate settings, as follows:

Here the configuration of the mail client needs to use the authorization code, the details are solved by Baidu.

3. Configure urls file

First, we need to configure the urls file of the project, as shown in the figure:

Then there is the applied urls file. By default, the applied urls file does not exist, so we need to create a new urls.py file and then write the content into it. As for the content, it actually introduces the routing function we wrote in the view file, and we first write all the routing functions in it, as shown in the figure:

Fourth, create a model

Because we are working on a website and have the functions of logging in and registering, we need to have users, passwords and mailboxes. First, write to the models.py file in the web application, as shown below:

5. Form

Then we need to write a form for the user to enter, as shown in the figure:

VI. The compilation of view function

If you want the website to run successfully, you must have the support of the view function, as shown in the figure:

Seventh, the compilation of the front-end page

If you want the front-end data to be processed in the background, then the front-end page should also be written. Django, like flask, provides a complete set of mvt design patterns, which greatly reduces the front-end code and ensures security.

Create a database migration

This step is very important. If you use database storage and you do not create a migration, then the project will make mistakes. Generally speaking, two steps are ok, as follows:

Python manage.py makemigrations # create database migration file python manage.py migrate # generate the corresponding SQL statement based on the database migration file and execute

Please be sure to do it in the order given by the editor for the first time.

IX. Start the project

Cmd enter the command to start the project, as shown in the figure:

Then let's take a look at the final effect, as shown in the figure:

Note: there are still many functions that the editor has not demonstrated one by one, mainly because it is too hard to capture the demo screen gif generation, but the functions are relatively complete, although the code is not so beautiful.

As the GIF picture has more than 300 frames, can not be uploaded to the background, so you can not see the complete dynamic picture, the editor put the dynamic picture here in Github.

Https://github.com/cassieeric/python_crawler/tree/master/DjangoWebDevelopAutoLogin at this point, on the "Django website actual combat to make a classic website method tutorial" on the end of the study, I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report