Django自定义网页

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的默认页面。

Django Custom Webpage 1

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”。

Django Custom Webpage 2

Django Custom Webpage 3

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网站的管理页面。

Django Custom Webpage 4

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/)将帮助我们最终使用数据库,但是我们现在不必真正担心这一点。

如何更改现有网页的URL (How to Change URL of Existing Webpages

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值