django简单实例(1)

Posted on   风行天下-2080  阅读(456)  评论(0编辑  收藏  举报

1、((django配置相关和简单的登录实例))

2、helloworld实例

3、django3连接mysql数据库并创建表

4、django3创建网页

 

************************************************************************************************************************************

1、https://www.cnblogs.com/wangkaiok/p/10346807.html 
((django配置相关和简单的登录实例))

   https://www.liujiangblog.com/course/django/165    (django2.2全面教程)

2、创建helloworld的实例

django环境:

 

 

 

 

views.py内容:

from django.http import HttpResponse
from django.shortcuts import render
def index(request):
return HttpResponse("Hello, world")

url.py内容:

from django.contrib import admin
from django.urls import path
from . import views

urlpatterns = [
path('admin/', admin.site.urls),
path('', views.index),
]
在当前目录运行:mysite>python3 manage.py runserver 127.0.0.1:8000
————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
3、
https://www.cnblogs.com/wutao666/p/9508801.html (django连接mysql数据库,并创建一个表)
上面在创建的时候有个报错:django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on '10,1.xx.xx' ([Errno 11001] getaddrinfo failed)")
处理方法:https://www.cnblogs.com/memory-ccy/p/12737741.html
————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
4、
https://blog.csdn.net/zhangcongyi420/article/details/102313888 (创建网页)
结构如下:

 

 在url.py中的urlpatterns中添加一个path的路径配置,

path('mysite/',views.index),     ####mysite名字随便起

然后去views.py中定义函数

#跳转视图页面
def index(request):
    return render(request,'index.html')
index.html内容随便写
然后启动项目,进行访问:http://127.0.0.1:9000/mysite/

 ————————————————————————————————————————————————————————————————————

5、

 

——————————————————————————————————————————————————————————————————————

 

 

 

6、



11111




编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?

随笔 - 618, 文章 - 0, 评论 - 6, 阅读 - 37万

Copyright © 2025 风行天下-2080
Powered by .NET 9.0 on Kubernetes

点击右上角即可分享
微信分享提示