0

我在我的 django 网站上有一个可过滤的表,我已经添加了一个列。但是,在插入获取数据的代码后,我现在在刷新页面时收到此错误:

DataTables warning: table id=table - Requested unknown parameter 'pname' for row 0, column 9. For more information about this error, please see http://datatables.net/tn/4 

我的网站有两个数据库。最初是一个 sphinx 数据库,然后它通过第二个设置文件中的 databases.update() 使用 postgres 数据库进行更新。

我将该列添加到 postgres 和 sphinx 中。我通过查看sphinx mysql数据库已经确认它在sphinx中(自然我也检查了postgres,并且该列可以在其他区域拉起)。我通过停止 sphinx 添加它,在 .conf 文件中将该列添加为“rt_attr_string”,清除“var/lib/sphinxsearch/data”中的数据,然后重新启动 sphinx。

连接到表的代码是:

应用程序/conf.py

USER_TABLE_COLUMNS = [
  dict(
     name = "column1",
     orderable = False,
   ),
  dict(
     name = "newcolumn",
     orderable=False,
  )
]

(请记住,为简单起见,我删除了额外的列/重命名了它)

在views.py内部:

class ListView(appViewBase):
    template_name = "app/list.html"

    @method_decorator(login_required)
    @method_decorator(permission_required("sig.app.view", raise_exception=True))
    def dispatch(self, request, *args, **kwargs):
        return super().dispatch(request, *args, **kwargs)

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        self.request.js_storage.update(
            group_table_columns=GroupTable.get_columns(self.request.user),
            users_table_columns=itemTable.get_columns(self.request.user)
        )

        table_mode = self.request.GET.get("table_mode", conf.TABLE_MODE_GROUPS)
        if table_mode not in dict(conf.TABLE_MODE_CHOICES):
            table_mode = conf.TABLE_MODE_GROUPS

        context.update(
            filters=utils.get_filters(self.request, table_mode),
            table=utils.get_table(self.request, table_mode),

            table_mode=table_mode,
            table_mode_title=utils.get_table_mode_display(table_mode),
            table_choices=conf.TABLE_MODE_CHOICES,
        )
        return context

在 sphinx.py 里面


class subitem(spx_models.SphinxModel):

    #added code for the name here
    #seems to be listing the columns that exist in the table
    column1 = models.CharField(max_length=32)
    newcolumn = spx_models.StringField(default=0)

    objects = subitemManager()
    
    #Choosing which table it is pulling from
    class Meta:
        managed = False
        db_table = 'sphinx_table'

    def fill_from(self, subitem, group=None, lang_ids=None):
        item = subitem.item


        #Added code for name section here
        #This is simply telling the app which columns to pull from
        self.column1 = item.column1
        self.newcolumn = subitem.newcolumn

主要的 html 模板是从表中拉出来的,所以我只是把它放在这里......

<table id="table" class="table table-list table-hover full-width-table table-users" data-per-page="{{ entries_per_page }}" style="width: 100%">
  <thead>
  <tr>
    <th>
        <span class="blue-tooltip"
              data-toggle="tooltip"
              data-placement="bottom"
              title="">column1</span>
    </th>
    <th>
        <span class="blue-tooltip"
              data-toggle="tooltip"
              data-placement="bottom"
              title="">newcolumn</span>
    </th>
  </tr>
  </thead>
</table>

我不确定我是否错过了另一个要编辑的地方……(这个项目是传给我的,但最初不是我的)。表格中有 JS,但它似乎只是在提取格式,而不是与查询交互......我真的很茫然,所以任何帮助都会很棒。

谢谢!

4

0 回答 0