【无标题】

除了之前的一些 就外键 ForeignKey 还有日期 一些 格式
其他就是 讲的一些 注册 登录 欢迎XX登录 添加 转跳到外键id的页面 进行 修改删除
下面就是存代码

class CountryView(View):
def get(self,request):
date=Country.objects.all()
dix={‘info’:date}
return render(request,‘index.html’,dix)

Title 分页面 {% for foo in info %}
        {% endfor %}


    </table>
编号城市名城市特点所属国家详细
{{ foo.id }}{{ foo.name }}{{ foo.te }}{{ foo.suo }} 删除 修改

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

urlpatterns = [
path(‘admin/’, admin.site.urls),
path(‘index/’,views.CountryView.as_view()),
path(‘fen/int:pk/’,views.cityViwe.as_view()),
path(‘del/int:pk/’,views.DelViwe.as_view()),
path(‘update/int:pk/’,views.UpdataViwe.as_view()),
]

class cityViwe(View):
def get(self,request,pk):
book=city.objects.filter(suo=pk)
desc={‘info’:book}
return render(request,‘fen.html’,desc)

class DelViwe(View):
def get(self,request,pk):
city.objects.filter(id=pk).delete()
return redirect(‘/fen/’)

还要注意那个 csrf的报错 403
加一个{{CSRF}} 或者在 settings里面 # ‘django.middleware.csrf.CsrfViewMiddleware’,
把这一句注释掉 防止csrf错误

报错
RuntimeError: ‘cryptography‘ package is required for sha256_password or caching_sha2_password auth m
执行 python manage.py runserver 时报错:

  File "/Users/jason93/Desktop/PythonProject/django_drf/venv-djdrf/lib/python3.9/site-packages/pymysql/_auth.py", line 204, in sha2_rsa_encrypt
    raise RuntimeError("'cryptography' package is required for sha256_password or caching_sha2_password auth methods")
RuntimeError: 'cryptography' package is required for sha256_password or caching_sha2_password auth methods

说 cryptography 这个包需要安装,则打开终端用pip进行安装,但发现安装不上:

(venv-djdrf) jason93@92 djangodrf % pip install cryptography
ERROR: Could not find a version that satisfies the requirement cryptography
ERROR: No matching distribution found for cryptography
(venv-djdrf) jason93@92 djangodrf % 
然后打开setting在pip管理中下载

然后重新进行启动就好了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值