django - 如何在我的模板中显示租户模式名称 - django?
问题描述
我正在尝试在我的一个表数据中返回租户模式名称,并且我正在使用django-tenant这就是我想要实现的目标
class Vistor(models.Model):
admin = models.ForeignKey(User,on_delete=models.PROTECT,default=1)
full_name = models.CharField(max_length=150)
@login_required
def daily_vistors_detail_html(request,day):
lists = BookingVisitor.objects.annotate(day=TruncDay('date')).filter(day=day).order_by('-pk')
context = {
'lists':lists
}
有时我必须用它的租户域返回数据!
<table class="w-full text-center table-auto display nowrap" style="width:100%" id="vistors">
<thead>
<tr>
<th class="p-2 text-xs text-white bglightpurple md:text-base">{% trans "admin" %}</th>
<th class="p-2 text-xs text-white bglightpurple md:text-base">{% trans "full name" %}</th>
<th class="p-2 text-xs text-white bglightpurple md:text-base">{% trans "tenant name" %}</th>
</tr>
</thead>
<tbody id="list_vistors_daily" class="w-full">
{% for i in lists %}
<tr>
<td class="p-2 text-xs border border-purple-900 md:text-base textpurple">{{i.admin}}</td>
<td class="p-2 text-xs border border-purple-900 md:text-base textpurple">{{i.visitor.full_name}}</td>
<td class="p-2 text-xs border border-purple-900 md:text-base textpurple">{{tenant name}}</td><!-- this is should return the current tenant name -->
有没有办法从视图中返回当前租户名称?!提前谢谢你
解决方案
推荐阅读
- sql - 显示 Column1 的数据,其中包含第 2 列中提到的值
- google-apps-script - Apps 脚本:以日/月/年格式为多列增加日期
- flutter - 如何使其影响设备字体大小到 RichText 和 TextSpan
- javascript - 用 React 处理页面中所有状态的最佳方法是什么?
- azure-blob-storage - 为什么我无法使用托管标识连接到我的 Azure Blob 存储帐户?
- mql5 - MQL5 中的无效到期订单发送专家
- scala - Scala Month函数抛出错误没有枚举常量java.time.Month.UNDEFINED
- python - 访问 django 数据库对象的元素
- javascript - 我如何动态获得前 3 或 5 个财政年度。例如 2021-20、2020-19
- xamarin - Quickblox.sdk GetBaseSession() 方法抛出“nonce is required”错误