码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 飞天使-template模版相关知识


    遇到报错django.template.exceptions.TemplateSyntaxError: ‘staticfiles’ is not a registered tag library. Must

    ROOT_URLCONF = ''
    
    TEMPLATES = [
        {
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': [os.path.join(BASE_DIR, 'templates')]
            ,
            'APP_DIRS': True,
            'OPTIONS': {
                'context_processors': [
                    'django.template.context_processors.debug',
                    'django.template.context_processors.request',
                    'django.contrib.auth.context_processors.auth',
                    'django.contrib.messages.context_processors.messages',
                    
                ],
                #添加下面内容
                'libraries': { # Adding this section should work around the issue.
                    'staticfiles' : 'django.templatetags.static',
                },
            },
        },
    ]
    解决办法参考链接:https://www.cnblogs.com/yizhipanghu/p/15346297.html
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24

    html 模版中新增一个图片

        
    学生信息
    #STATICFILES_DIRS --- 全局变量定义了存储静态文件集合 STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'), os.path.join(BASE_DIR, 'abc'), os.path.join(BASE_DIR, 'app01', 'static') ]
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    在这里插入图片描述

    url 跳转-A标签(链接)

            
    综艺首页
    ``` #### redirect 关键字处理跳转 用户没有登陆直接跳转到登陆页面 from django.shortcuts import render from django.shortcuts import redirect # Create your views here. def index(request): # 首页 # url记录登录名 --- ? username=alice username = request.GET.get("username") # 如果获取到username值,直接显示首页,获取不到;调到登录页 if username: return render(request, 'index.html') else: # 跳转到登录页 return redirect("/login/")
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24

    多app下的templates 环境准备

    setting 里面设置
    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'home',
        'tv',
        'movie',
    ]
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    多app下模块的应用

    每个app 会有一个index.html ,多个app会出现重复情况
    则每个app下面可以建立一个相同app名字,比如tv ,tv/index.html ,xx ,xx/index.html
    
    • 1
    • 2

    在这里插入图片描述

  • 相关阅读:
    对于聚合物聚乙二醇PEG大家了解多少了?以及在生活中的应用
    嵌入式单片机智能药盒设计(含代码)
    这10 个很“哇塞”的Web资源,前端必备的神仙级网站
    仿牛客网项目---用户注册登录功能的实现
    【Leetcode】1829. Maximum XOR for Each Query
    JAVA基础12:字符串(上)
    JavaSE——类和对象 重点梳理
    有哪些靠谱的程序员兼职平台?
    2023年苏工展丨合共软件诚邀您参观苏州工业制造展,全新一代制造运营管理平台RockPlus MOM即将亮相!
    JSON flag table for Link not found for toolset v143 v143
  • 原文地址:https://blog.csdn.net/startfefesfe/article/details/134383857
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号