我正在Django的HStoreField上工作。我可以将数据存储在HstoreField()中。 但我不知道如何从hstore提交的数据中检索数据
models.py
class myhstore(models.Model):
file_name= models.CharField(max_length = 20)
content = HStoreField()
我将数据存储为
file_name =“Sample.csv”
content
{'Name':'A','Age':'21','Place':'AAA'}
{'Name':'B','Age':'20','Place':'BBB'}
{'Name':'C','Age':'21','Place':'CCC'}
{'Name':'D','Age':'20','Place':'AAA'}
{'Name':'E','Age':'21','Place':'CCC'}
{'Name':'F','Age':'22','Place':'AAA'}
并且在Postgre表中它存储为
"Name"=>"A", "Age"=>"21", "Place"=>"AAA"
"Name"=>"B", "Age"=>"20", "Place"=>"BBB"
"Name"=>"C", "Age"=>"21", "Place"=>"CCC"
"Name"=>"D", "Age"=>"20", "Place"=>"AAA"
"Name"=>"E", "Age"=>"21", "Place"=>"CCC"
"Name"=>"F", "Age"=>"22", "Place"=>"AAA"
在这里,我需要使用python从表中查询 如
如果选择“Place”需要就地值及其计数
AAA - count- 3 BBB - 计数-1 CCC - count- 2
如果选择“地点”和“年龄”
AAA,21 - count - 1
AAA,20 - count - 1
AAA,22 - count - 1
BBB,20 - 计数 - 1CCC,21 - count - 2
请帮我这样做..
先谢谢..