htsql django和manytomany的关系

时间:2012-09-07 16:02:04

标签: django htsql

在HTSQL中,您可以查询多种关系吗?

在我的Django项目中(应用名称为config)我有一个与Chapter具有ManyToMany关系的模型FileName。 当我查看实际的sqlite3数据库时,我看到表config_chapter_filenames,(当然所有django管理员的东西都按预期工作)。但是当我打开一个HTSQL shell会话时,表没有列出:

htsql-ctl shell -E tweak.django sqlite:/mydb.sqlite  -E tweak.meta
/meta(/table)

它列出了我的每个模型的表格,但没有列出多种关系。

我无法弄清楚会列出每章的文件名的查询。我猜测,如果HTSQL没有看到我可以解释问题的多种关系。

有什么想法吗?

在htsql shell中,我看到了模型:

config_chapter                         
config_chapter_filenames  

这是我的模特:

class Chapter(models.Model):
    book = models.ManyToManyField(Book, through='ChapterMembership')
    parent = models.ForeignKey(Book, related_name = '+')
    filenames = models.ManyToManyField(FileName)

我正在尝试的网址是:

http://machinename/htsql/config_chapter{name,filenames}

我收到此错误:

bind error: unrecognized attribute 'filenames' in scope of 'config_chapter':
    /config_chapter{name,filenames}
                     ^^^^^^^^^

否则我可以查询并获取章节和父级的名称,但仍然不是文件名。我对introspect.py进行了更改,停止了我的apache服务器并重新启动。 还有其他我想念的东西吗?

还有一件事,在htsql shell中:

describe config_chapter
Slots for `config_chapter` are:
     id                       integer
     parent_id                integer
     name                     string
     title                    string
     parent                   SINGULAR(config_book)
     config_chapter_filenames PLURAL(config_chapter_filenames)

1 个答案:

答案 0 :(得分:1)

相关问题