Django
- 9 ответов
- 0 вопросов
2
Вклад в тег
These profile models are not special in any way - they are just Django models that happen to have a one-to-one link with a user model. As such, they aren’t auto created when a user is created, but a django.db.models.signals.post_save could be used to create or update related models as appropriate.
class AuthUser(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(u'Электронная почта', unique=True)
date_add = models.DateTimeField(u'Дата добавлен', auto_now_add=True)
is_active = models.BooleanField(u'активен', default=True)
employee = models.OneToOneField('person.Employies', null=True, blank=True, editable=True, verbose_name='Профиль сотрудника', on_delete=models.PROTECT)
is_staff = models.BooleanField(u'администратор', default=False
, help_text=u'определяет возможность входа в панель управления')
roles = models.ManyToManyField(AuthUserRoles, verbose_name=u'Роли')
objects = AuthUserManager()
class AuthorDetailView(DetailView):
model = Author
template_name = 'catalog/author_detail.html'
def get_context_data(self, **kwargs):
context = super(AuthorDetailView, self).get_context_data(**kwargs)
context['author_books'] = Book.objects.filter(author=pk).values('title', 'summary')
return context