我不知道如何在Mezzanine中添加此模型的权限:
class SitePermission(models.Model):
"""
Permission relationship between a user and a site that's
used instead of ``User.is_staff``, for admin and inline-editing
access.
"""
user = models.OneToOneField(user_model_name, verbose_name=_("Author"),
related_name="%(class)ss")
sites = models.ManyToManyField("sites.Site", blank=True,
verbose_name=_("Sites"))
class Meta:
verbose_name = _("Site permission")
verbose_name_plural = _("Site permissions")
如何在视图中将特定用户添加到特定网站?我没有找到任何关于此的文件。
答案 0 :(得分:0)
以下是如何操作:
from mezzanine.core.models import SitePermission
siteperms = SitePermission.objects.create(user=user)
siteperms.sites.add(site)