我在我的python脚本中创建了一个变量。我想在我的页面上显示这个变量的值。因此,我将变量传递给一个字典,并调用HTML文件上的键。但是,当我刷新我的页面时,它没有显示任何错误,而且值也没有显示。我是python的新手,我不知道问题出在哪里。有没有办法在使用前启用这个模板标签{{ }}? 就像这样: Python函数 from django.shortcuts import render
def about(request):
my_name = 'Hello! My name is Andi@ITech'
return rende
我正在努力部署我的应用程序,并且已经在Windows上完成了大部分工作。但是,现在我已经把它移到AWS了,它不再工作了。
在任何人链接其他文章之前,这里列出了我尝试过的所有内容:
在TEMPLATE_DIRChanging中添加os.path.join(BASE_DIR,'templates')我的模板的权限我的应用程序在INSTALLED_APPS变量中,我检查了所有render方法都是格式化的
正如我前面说的,它在我的Windows机器上工作,只是不工作在AWS或我的Mac上。更奇怪的是,错误说
Django tried loading these templates, i
因此,我使用Django框架将控制台输出显示到HTML。为了执行这个命令,我使用了Python中的check_output of subprocess模块。它接收来自HTML输入表单的输入。问题是,我只在HTML页面上看到"None“,这是output在views文件中的默认值。下面是视图文件和HTML文件的代码。我是个新手,所以我很感谢你的帮助。
Views.py
from django.shortcuts import render
from django.shortcuts import redirect
from .forms import command_form
impor
尝试显示页以更新记录,但收到以下错误。
误差
NoReverseMatch at /edit-expense/2
Reverse for 'edit-expense' with no arguments not found. 1 pattern(s) tried: ['edit\\-expense/(?P<id>[0-9]+)$']
Request Method: GET
Request URL: http://127.0.0.1:8000/edit-expense/2
Django Version: 3.2.5
Exception Type:
从im入门到Django框架和python语言。我需要帮助。我需要从html按钮中运行外部python脚本,也可以从html获得值,并将输出显示回网页。
工作流程示例:
Input text : "hello", click "submit" on html button.
Run world.py : receive "hello" as variable. Add "world"
Post it back to the same html page and shows "helloworld" .
我正在开发一个带有Django和PostgreSQL支持的web应用程序。我正在使用Psycopg2连接我的PostgreSQL数据库。我试图在我的Home.html文档中列出我的数据库中的所有表。
我在Home.html文档中显示这一点有困难。下面我包含了我的代码。
models.py
from django.db import models
import psycopg2
# Create your models here.def __init__(self, db='giquery-data'):
class Tables(models.Model):
co
我正在尝试在django项目上设置django-openid-auth。我遵循了的步骤1-8,并尝试在我的服务器上访问/openid/login/。然而,当我读到那一页时,我看到
TemplateSyntaxError at /openid/login/
Could not parse the remainder: '-logo' from 'openid-logo'. The syntax of 'url' changed in Django 1.5, see the docs.
我有点困惑,因为这是在一个模板中包括在应用程序-我不是自己写的模