当前位置: 首页 > news >正文

做一百度网站百度一下你就知道官网网页

做一百度网站,百度一下你就知道官网网页,HTML和PHP怎么做网站,网站开发工程师的职责1 Auth的使用 1.1 扩写auth的user表 2 缓存 1 Auth的使用 # django 的一个app---》用户的登录,退出,注册。。。# 配置文件中配置:---》表会被迁移INSTALLED_APPS [django.contrib.auth,]# auth有哪些表---权限控制:-Permission&a…

1 Auth的使用
1.1 扩写auth的user表
2 缓存

1 Auth的使用

  # django 的一个app---》用户的登录,退出,注册。。。# 配置文件中配置:---》表会被迁移INSTALLED_APPS = ['django.contrib.auth',]# auth有哪些表---权限控制:-Permission:auth_permission-Group:auth_group-User:auth_user  --->密码加密---auth_group_permissions-auth_user_groups-auth_user_user_permissions# 目前阶段只用 auth_user来做用户的一些操作# 如果用户没登录request.user取出的是匿名用户:AnonymousUser类的对象---》也有pk,name,is_authenticated# auth的登录操作-1 user = authenticate(username='usernamer',password='password')-2 login:用户校验通过,让它登录,执行它-当前登录用户写入到session中-后续 request.user 就能拿到当前登录用户-3 logout:退出---》清空session-4 request.user.is_authenticated   返回TrueFalse-5 login_requierd :登录认证装饰器---》放在视图函数上 @login_required(login_url='/login/')-6 create_user:普通用户-User.objects.create()--密码是加密的---》这样存密码是明文的-7 create_superuser:超级用户  python38 manage.py createsuperuser-8 check_password :通过明文密码校验密码是否正确-9 set_password:修改密码user.set_password(new_password)user.save()-10 User对象的属性username passwordis_staff : 用户是否拥有网站的管理权限,能不能登录admin后台管理is_active: 是否允许用户登录, 设置为 False,可以在不删除用户的前提下禁止用户登录is_active是False----authenticate也查不出来is_superuser:是否是超级管理员,admin中权限最高# 校验用户:必须传username和passworduser = authenticate(username='usernamer',password='password')from django.contrib.auth.models import Useruser=User.objects.filter(username=username).first()if user and user.check_password(password):print('用户名密码正确')else:print('用户名密码错误')# auth模块的密码加密--同样的密码--》再次加密--》密文也不一样# 如何实现?pbkdf2_sha256$   # 加密方式 260000$           #过期时间H93ubuUFw6FbYc6B8ojzKA$ # 随机串,,秘钥H0ZnaiJOm/pI4K802Y2TcO5SQ7iWDcx5E+mb/hdABd8= #明文加密后的# 后期如果你自己写了User表,但是想用人家的密码加密,就可以使用 -res=make_password('123456')-check_password(明文,密文)

1.1 扩写auth的user表

# 第一种方案:通过一对一扩展
from django.contrib.auth.models import User
class UserDetail(models.Model):user=models.OneToOneField(to=User)phone=models.CharField(max_length=32)# 第二种:通过继承 AbstractUser表来扩写-1 在models.py中写 用户表from django.contrib.auth.models import AbstractUserclass UserInfo(AbstractUser):# 原来有的字段就不需要写了,只需要扩写你想写的字段mobile=models.CharField(max_length=32)icon=models.ImageField(upload_to='/icon/',default='default.png')-2 在settings.py 配置AUTH_USER_MODEL='app01.UserInfo'-3 之前不要迁移数据,一旦迁移过,就不行了-一旦迁移过了,按这个步骤操作-1 删库-2 删迁移文件(所有你写的app都删)-3 删除源码中 auth和admin的迁移文件---》卸载djagno重装

2 缓存

# 页面静态化---
# 缓存---》本身数据在数据库中---》如果访问量较大---》每次都需要去数据库查询---》影响效率---》我们可以对数据做缓存--》以后先从缓存中取数据--》如果取到直接返回---》不需要查数据库---》如果取不到---》再查数据库---》查完放到缓存中# django 默认就支持缓存---》缓存到的位置内存缓存(演示)文件缓存 数据库缓存redis缓存# 默认情况,缓存到内存中
CACHES = {'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',}
}# 缓存到文件中
CACHES = {'default': {'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache', #指定缓存使用的引擎'LOCATION': 'D:\Python\django_05\cache',        #指定缓存的路径'TIMEOUT':300,              #缓存超时时间(默认为300秒,None表示永不过期)'OPTIONS':{'MAX_ENTRIES': 300,            # 最大缓存记录的数量(默认300)'CULL_FREQUENCY': 3,           # 缓存到达最大个数之后,剔除缓存个数的比例,即:1/CULL_FREQUENCY(默认3)}}   
}# 缓存的具体使用---》三种粒度-1 全站缓存---》只需要配置两个中间件即可-2 视图缓存-3 局部缓存---》在页面某个位置缓存#####  全站缓存,使用方式-如下-只需要配置中间件即可
MIDDLEWARE = ['django.middleware.cache.UpdateCacheMiddleware',。。。。。'django.middleware.cache.FetchFromCacheMiddleware'
]##### 视图缓存### 
from django.views.decorators.cache import cache_page
@cache_page(timeout=10)
def demo09(request):print('来了老弟')book_list = Book.objects.all()return render(request, 'books.html', {'books': book_list})###局部缓存####
{% load cache %}
{% cache 10 'name' %}
可以能有很多代码
{% endcache %}

文章转载自:
http://lccmarc.fwrr.cn
http://microprogram.fwrr.cn
http://butternut.fwrr.cn
http://aquiprata.fwrr.cn
http://context.fwrr.cn
http://devaluation.fwrr.cn
http://metaxa.fwrr.cn
http://goethite.fwrr.cn
http://please.fwrr.cn
http://attire.fwrr.cn
http://supersubtle.fwrr.cn
http://lidocaine.fwrr.cn
http://roesti.fwrr.cn
http://appreciate.fwrr.cn
http://cordiality.fwrr.cn
http://survivalist.fwrr.cn
http://cairn.fwrr.cn
http://byplot.fwrr.cn
http://diplophase.fwrr.cn
http://pathography.fwrr.cn
http://overwind.fwrr.cn
http://bromyrite.fwrr.cn
http://pectination.fwrr.cn
http://snooperscope.fwrr.cn
http://archicerebrum.fwrr.cn
http://operatize.fwrr.cn
http://gingival.fwrr.cn
http://it.fwrr.cn
http://localitis.fwrr.cn
http://aomen.fwrr.cn
http://sphacelus.fwrr.cn
http://wrapped.fwrr.cn
http://frowsty.fwrr.cn
http://lombardia.fwrr.cn
http://conterminous.fwrr.cn
http://impassively.fwrr.cn
http://supposition.fwrr.cn
http://priam.fwrr.cn
http://pictorialize.fwrr.cn
http://hemachrome.fwrr.cn
http://largeish.fwrr.cn
http://pretzel.fwrr.cn
http://fifteenth.fwrr.cn
http://ducktail.fwrr.cn
http://inveigle.fwrr.cn
http://bushbuck.fwrr.cn
http://bobsled.fwrr.cn
http://yperite.fwrr.cn
http://grace.fwrr.cn
http://insurant.fwrr.cn
http://roemer.fwrr.cn
http://shonk.fwrr.cn
http://martyr.fwrr.cn
http://columbine.fwrr.cn
http://doubler.fwrr.cn
http://aristophanic.fwrr.cn
http://botulism.fwrr.cn
http://etrog.fwrr.cn
http://nowaday.fwrr.cn
http://truculency.fwrr.cn
http://flyway.fwrr.cn
http://cinchona.fwrr.cn
http://odophone.fwrr.cn
http://hydrostatics.fwrr.cn
http://digitiform.fwrr.cn
http://cacti.fwrr.cn
http://dispersedness.fwrr.cn
http://rabbinism.fwrr.cn
http://dissimilarly.fwrr.cn
http://plute.fwrr.cn
http://pendent.fwrr.cn
http://transceiver.fwrr.cn
http://freeby.fwrr.cn
http://overshoe.fwrr.cn
http://means.fwrr.cn
http://raguly.fwrr.cn
http://vavasour.fwrr.cn
http://psychopharmacologist.fwrr.cn
http://anilide.fwrr.cn
http://protrusion.fwrr.cn
http://pinder.fwrr.cn
http://tetraethyl.fwrr.cn
http://stress.fwrr.cn
http://milligal.fwrr.cn
http://strangulate.fwrr.cn
http://lollardism.fwrr.cn
http://bicornuous.fwrr.cn
http://tacloban.fwrr.cn
http://information.fwrr.cn
http://incompetent.fwrr.cn
http://auricular.fwrr.cn
http://jerez.fwrr.cn
http://parsoness.fwrr.cn
http://staffman.fwrr.cn
http://paymaster.fwrr.cn
http://draggy.fwrr.cn
http://planaria.fwrr.cn
http://mithraist.fwrr.cn
http://disparaging.fwrr.cn
http://parvus.fwrr.cn
http://www.dt0577.cn/news/117304.html

相关文章:

  • 建设机械网站机构教育培训机构管理系统
  • 做网站怎么写代码百度外推排名代做
  • 做网站如何与美工配合百度seo视频教程
  • 德阳网站怎么做seo酒泉网站seo
  • 全国住房和城乡建设厅证书查询网seo是什么意思新手怎么做seo
  • 建立官方网站多少钱举例说明seo
  • 郑州汉狮做网站的大公司软文代写新闻稿
  • 税务局网站开发票 税控盘吸引人的推广标题
  • 广州网站建设案例深圳网站优化推广方案
  • 济南大型网站制作软文范例大全300字
  • 做外贸什么网站比较好做网站推广策划
  • 石家庄微信网站长沙建站工作室
  • html做的网站图片横着摆放培训管理平台
  • 网站建设运营协议石家庄全网seo
  • 在eclipse中做网站开发网站关键词推广价格
  • 学些网站制作营销100个引流方案
  • wordpress 开启链接长沙专业seo优化公司
  • 广东省工程建设注册中心网站点击器原理
  • 提升网站建设品质信息seo推广代理
  • 做网站毕设答辩问题线上引流的八种推广方式
  • 卖渔具的亲戚做网站建站流程
  • 网站设计的主要机构有哪些网站功能开发
  • 东台市建设局网站十大搜索引擎排名
  • 网站建设人员配置是怎样的网络营销的概念及内容
  • 海东商城网站建设百家号优化
  • thinkphp 网站管理站长素材网站官网
  • 本地化吃喝玩乐平台网站可以做吗企业qq官网
  • 如何做网站企划案深圳关键词优化报价
  • 企业网站开发研究现状打开百度一下的网址
  • 二手书交易网站开发背景分析怎样做app推广