Tutorial App

help app

tutorial update

作者: n5321

tutorial update

tutorialtest下面的App感觉基本可用,考虑正式在mysite应用!

  1. 直接把相关scripts copy and past 进 mysite

    1. 报错ModuleNotFoundError: No module named 'tutorialsfiler'

      1. 语法错误:修改 INSTALLED_APPS,在 'tutorials' 后面加上逗号:

    2. requirements.txt里面的东西更新得足够吗?

  2. tutorials的设计:

    1. 最初的目的是做AutoEM的help,需要一个online的help来创造客户,解决客户的疑问。在结构上就期望类似SolidWorkshelp。左侧是sidebar,大目录,中间是内容,右侧是考虑通过JS生成副标题link,再添加一个search。方便用户可以快速理解、使用AutoEM的工具。

    2. 一个card结构的list。暂时在结构上是能够接受的。当然还需要再弄漂亮一点!

    3. 一个detail页面也就是以上。

    4. 在creat上面就需要分类,一个tutorial create 一个chapter create

    5. 在edit and delete上也同样需要两类

    6. 有技术含量的内容是需要增加一个版本控制器。

  3. Debug的思路!从什么地方开始?尝试从view开始

  4. tutorials_detail :bug,AJAX没有发挥效果,href没有插入进去!

  5. tutorial and chapter都是内容,都应该有author,是要有固话!

    1. 不对,开始是想搞两个视图(1个tutorial detail 1个chapterdetail)

    2. 暂时搞定tutorial 页面。

  6. update create tutorial页面

    1. 是否要用crispy工具。html代码少了很多,有点不清楚它的logic怎么实现的。这是问题。推荐的理由是django example and chatgpt推荐。——结论还是用这个工具

    2. pip install django-crispy-forms -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

    3. pip install crispy-bootstrap5 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

    4. 问题:image存放的位置!包括未来的图片管理问题

    5. information structure的设计

    6. features(chapter的管理)

      1. 在视觉效果上跟那个是一样的,但是还是需要一个新的不一样的edit页面

      2. 加了好多东西,感觉好了很多。

      3. 加一个delete页面。(下午搞)——已添加,暂时感觉还不错

      4. list页面的card太丑了。需要update!

      5. order那里还有一个小bug!如果中间删了一个order的话,缺一个list页面来同意改order!现在设置了一个逻辑在里面,要好好想一下到底要不要改!

    7. 增加books App(用fileshare好像不喜欢了)

      1. 添加PyMuPDF: pip install pymupdf -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

      2. books App的东西基本是在理解概念以后搭的。基本上直接挪过去就可以用了。算是一个小意外!

    8. 2025.3.5直接把update的内容部署到腾讯云上去了。出现两个bug

      1. 用的http,所以一直谈bug,说Cross-Origin-Opener-Policy的问题。为了屏蔽这个功能,在settings.py之中添加SECURE_CROSS_ORIGIN_OPENER_POLICY = None 并且考虑在Nginx配置里添加 #add_header Cross-Origin-Opener-Policy "unsafe-none" always;

        location / {
            proxy_pass http://124.220.90.88:8000; # 假设你的应用运行在此端口
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            add_header Cross-Origin-Opener-Policy "unsafe-none" always;
        }  

         Nginx的原始配置如下(备用)                                                          
         
            # Read up on ssl_ciphers to ensure a secure configuration.
            # See: https://bugs.debian.org/765782
            #
            # Self signed certs generated by the ssl-cert package
            # Don't use them in a production server!
            #
            # include snippets/snakeoil.conf;

            root /var/www/html;

            # Add index.php to the list if you are using PHP
            index index.html index.htm index.nginx-debian.html;

            server_name _;

            location / {
                    # First attempt to serve request as file, then
                    # as directory, then fall back to displaying a 404.
                    try_files $uri $uri/ =404;
            }

            # pass PHP scripts to FastCGI server
            #
            #location ~ \.php$ {
            #       include snippets/fastcgi-php.conf;
            #
            #       # With php-fpm (or other unix sockets):
            #       fastcgi_pass unix:/run/php/php7.4-fpm.sock;
            #       # With php-cgi (or other tcp sockets):
            #       fastcgi_pass 127.0.0.1:9000;
            #}

            # deny access to .htaccess files, if Apache's document root
            # concurs with nginx's one
            #

      2. 以上update以后,可以上传,但是有文档限制,在1M以内。提示明确是nginx的限制

      3. http 块中添加或修改 client_max_body_size 指令。您可以将其放在 http 块的任何位置,通常放在块的开头或末尾,如下所示:

        nginx复制编辑http {
          client_max_body_size 150M;
           
          # 其他配置
        }
      4. 一开始做的这个: 结果无效:2. server 块中设置(针对特定的 server 配置)

        如果只希望为某个特定的 server 设置限制,可以将该指令放在 server 块中:

        nginx复制编辑server {
          listen 80 default_server;
          listen [::]:80 default_server;

          client_max_body_size 150M;

          # 其他配置...
        }

      暂时解决问题!