In this tutorial, we’re going to create our first custom webpage in django. The main goal of this article for you to understand the whole flow of information in django website like if someone asks for specific url then how do we route them into the correct places and ultimately give them back some HTML.
在本教程中,我们将在Django中创建第一个自定义网页。 本文的主要目的是让您了解django网站中的整个信息流,例如,如果有人要求特定的URL,那么我们如何将它们路由到正确的位置并最终给他们一些HTML。
So before starting this article I am assuming that you’ve started the local server using python3 manage.py runserver command in project directory.
因此,在开始本文之前,我假设您已经在项目目录中使用python3 manage.py runserver命令启动了本地服务器。
We’ve seen that whenever we create a project and run it in browser then django’s default page shows up.
我们已经看到,只要创建项目并在浏览器中运行它,就会显示django的默认页面。
That’s isn’t our creation right.
那不是我们的创作权利。
So let’s see how to create our own webpage in django.
因此,让我们看看如何在Django中创建自己的网页。
In previous articles, we’ve seen that anytime someone is looking for a URL on our website it comes to this “urls.py”.
在以前的文章中,我们已经看到,只要有人在我们的网站上查找URL,就会涉及到该“ urls.py”。
Currently we’ve path of admin/ in the list urlpatterns. That means when user goes to our website (currently = http://127.0.0.1:8000/) and add a /admin in the url, user will be redirected to admin page of our django website.
目前,我们在列表urlpatterns中有admin /路径。 这意味着当用户访问我们的网站(当前= http://127.0.0.1:8000/)并在URL中添加/ admin时,用户将被重定向到我们django网站的管理页面。
Note: That domain-name/admin (currently domain-name is http://127.0.0.1:8000/) is going to help us eventually work with the database but we don’t really need to worry about that right now.
注意:域名/管理员(当前域名为http://127.0.0.1:8000/)将帮助我们最终使用数据库,但是我们现在不必真正担心这一点。