简体   繁体   English

如何从某个数据库变量中获取项目?

[英]how to get item from certain database variable?

models.py:模型.py:

class VideoLibrary(models.Model):
    shop_id = models.AutoField(primary_key=True, unique=True)
    shop_name = models.CharField(max_length=264)
    adress = models.TextField(max_length=264, default='')

I have here shop_name and address.我这里有店名和地址。 The thing I need is to click a button which gets shop_name from text area and match it with address.我需要的是单击一个按钮,该按钮从文本区域获取 shop_name 并将其与地址匹配。 Is there any way to do it?有什么办法吗?

在此处输入图像描述

as I mentioned I need to get the name of shop from text area and then show its address.正如我提到的,我需要从文本区域获取商店名称,然后显示其地址。

you can simply validate in your form POST view您可以简单地在表单 POST 视图中验证

if request.POST.get('shop_name') == request.POST.get('adress'):
    # your code when matched
else
    # throw error

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 DJango 如何从 html 中的数据库表中 select 某些项目 - DJango How to select certain item from database table in html 使用Python和SQLite,如何将数据库中的项读入变量? - With Python and SQLite, how do i read an item from the database into a variable? 如何从Django数据库中获取一定数量的元素 - How to Get a Certain Number of Elements from a Django Database 无法使用请求从网页中获取特定项目 - Can't get a certain item from a webpage using requests 如何获取列表项并将其保存到python中的数据库 - How to get the list item and save it to database in python 使用产品后如何获取商品的特定索引 - How to get a certain index of an item after using product 如何使用discord.py从某些选项列表中可靠地获取用户输入作为变量? - How do I reliably get user input as a variable from a list of certain options using discord.py? 我如何获得一件物品,但前提是它是某个标签的兄弟姐妹 - How do I get an item but only if is a sibiling of a certain tag 如何从变量中删除某些字符? (蟒蛇) - How to remove certain characters from a variable? (Python) 如何让我的 HTML 按钮从 SQLite 数据库中删除正确的列表项? - How do I get my HTML button to delete the right list item from a SQLite database?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM