我有三个型号,分别为User
,Tenant
和TenantUser
。
我想这样输出
但是我不能写视图来显示这个
"models.py "
class Tenant(models.Model):
name = models.CharField(max_length=100)
memo = models.TextField(blank=True)
users = models.ManyToManyField(settings.AUTH_USER_MODEL,
through='db.TenantUser', blank=True)
agent_timezone = models.CharField(
max_length=30, choices=const.AGENT_TIMEZONES)
class TenantUser(models.Model):
user =
models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE)
tenant = models.ForeignKey('Tenant', on_delete=models.CASCADE)
ui_language_code = models.CharField(
max_length=5, choices=const.UI_LANGUAGE_CODES,
default=const.UI_LANGUAGE_CODES.japanese)
"forms.py"
from db import const
class EditMemo(forms.Form):
agent_timezone = forms.ChoiceField(choices=const.AGENT_TIMEZONES)
memo = forms.CharField(widget=forms.Textarea)
ui_language_code = forms.ChoiceField(choices=const.UI_LANGUAGE_CODES)
"Views.py"
class AccountSettingsView(LoginRequiredMixin,UpdateView):
# views Code here that can update two models tanant and tanantUser