问题描述
我想从TemplateView
内的表单发送django-tables2.table
看不见的参数:
class CustColumn(tables2.Column):
empty_values = list()
def render(self,value,record):
return mark_safe(f"""<form id="params" action="/product_all/" method="POST">
<button class="btn btn-secondary">
<input type="hidden" name="store_id" value="{record.get_shelf_id}"/>
<input type="hidden" name="store_name" value="record.name"/>
<span class="fas fa-eye"></span> view</button>
</form>""")
class ShelfTable(tables2.Table):
view = CustColumn(orderable=False)
class Meta:
model = Product
sequence = ("name","shop","view")
urls.py:
path(r"product_all/",views.ProductView.as_view(),name="product-all"),
视图:
class DeviceView(TemplateView):
template_name = "gbkiosk/device_all.html"
def get_context_data(self,*args,**kwargs):
shelf_id = str(kwargs["shelf_id"])
shelf_name = kwargs["shelf_name"]
devices = get_devices(shelf_id=shelf_id)
bus_numbers = list(set([int(d["bus_number"]) for d in devices ]))
context = {"store_id": kwargs["store_id"],"store_name": kwargs["store_name"],return context
我如何能够将CSRF令牌获取到该表格的表格中?我读过this,但并不完全了解它是否与我的问题有关,以及它如何帮助解决该问题。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)