Horizon CSRF token missing or incorrect
Hey!
I want to build my own panel in OpenStack's horizon webinterface.
My application constists of multiple TableTabs, whereas i want to filter my customer data on each of them seperately.
The filtering function works on the first tab perfectly, but on the second and third one I get the following error, when I want to filter for specific data:
"CSRF token missing or incorrect"
My code looks the following:
tabs.py:
class CustomersInformationTabConfigured(tabs.TableTab):
table_classes = (tables.CustomersInformationTableConfigured, )
name = _("Configured")
slug = "CRMCustomersConfigured"
template_name = ("horizon/common/_data_table.html")
preload = False
def get_customers_crm_configured_data(self):
customersConfigured = connector.returnCustomers(connector.selectCustomers('A'))[0:200]
#customers[0].name = self.request.GET.get(tables.CustomersInformationTableConfigured._meta.pagination_param, None)
return customersConfigured
class CustomersInformationTabA(tabs.TableTab):
table_classes = (tables.CustomersInformationTableA, )
name = _("A")
slug = "CRMCustomersA"
template_name = ("horizon/common/_data_table.html")
preload = False
def get_customers_crm_a_data(self):
customersA = connector.returnCustomers(connector.selectCustomers('A'))[0:200]
#customers[0].name = self.request.GET.get(tables.CustomersInformationTableConfigured._meta.pagination_param, None)
return customersA
class CustomersInformationTabB(tabs.TableTab):
table_classes = (tables.CustomersInformationTableB, )
name = _("B")
slug = "CRMCustomersB"
template_name = ("horizon/common/_data_table.html")
preload = False
def get_customers_crm_b_data(self):
customersB = connector.returnCustomers(connector.selectCustomers('B'))[0:200]
return customersB
tables.py:
class CustomerConfiguredFilterAction(tables.FilterAction):
def filter(self, table, customersConfigured, filter_string):
q = filter_string.lower()
def comp(customerConfigured):
if q in customerConfigured.name.lower():
return True
return False
return filter(comp, customersConfigured)
class CustomerAFilterAction(tables.FilterAction):
def filter(self, table, customersA, filter_string):
q = filter_string.lower()
def comp(customerA):
if q in customerA.name.lower():
return True
return False
return filter(comp, customersA)
class CustomerBFilterAction(tables.FilterAction):
def filter(self, table, customersB, filter_string):
q = filter_string.lower()
def comp(customerB):
if q in customerB.type.lower():
return True
return False
return filter(comp, customersB)
class CustomersInformationTableConfigured(tables.DataTable):
customers_id = tables.Column('cid', verbose_name=_("cid"))
customers_name = tables.Column('name', verbose_name=_("name"))
customers_admin = tables.Column('admin', verbose_name=_("admin"))
customers_group = tables.Column('group', verbose_name=_("group"))
customers_added = tables.Column('added', verbose_name=_("added"))
class Meta:
name = "customers_crm_configured"
verbose_name = _("CRM Customers Configured")
row_actions = (ConvertToOpenStackUserLink, )
table_actions = (CustomerConfiguredFilterAction, )
multi_select = False
class CustomersInformationTableA(tables.DataTable):
customers_id = tables.Column('cid', verbose_name=_("cid"))
customers_name = tables.Column('name', verbose_name=_("name"))
customers_admin = tables.Column('admin', verbose_name=_("admin"))
customers_group = tables.Column('group', verbose_name=_("group"))
customers_added = tables.Column('added', verbose_name=_("added"))
class Meta:
name = "customers_crm_a"
verbose_name = _("CRM Customers A")
row_actions = (ConvertToOpenStackUserLink, )
table_actions = (CustomerAFilterAction, )
multi_select = False
class CustomersInformationTableB(tables.DataTable):
customers_id = tables.Column('cid', verbose_name=_("cid"))
customers_name = tables.Column('name', verbose_name=_("name"))
customers_admin = tables.Column('admin', verbose_name=_("admin"))
customers_group = tables.Column('group', verbose_name=_("group"))
customers_added = tables.Column('added', verbose_name=_("added"))
class Meta:
name = "customers_crm_b"
verbose_name = _("CRM Customers B")
row_actions = (ConvertToOpenStackUserLink, )
table_actions = (CustomerBFilterAction, )
multi_select = False