如何在Django中处理高级标准认证模型?

时间:2015-06-30 09:27:09

标签: python django authentication

我有简化的用户模型

from django.db import models
from django.contrib.auth.models import User

class BasePerson(models.Model):
    account = models.OneToOneField(User)
    name = models.CharField(max_length=50, default='')
    patronymic_name = models.CharField(max_length=50, default='')
    surname = models.CharField(max_length=50, default='')
    dob = models.DateField()

    class Meta:
        abstract = True


class Performer(BasePerson):
    additional_performer_info = models.TextField(max_length=200)


class Director(BasePerson):
    additional_director_info = models.TextField(max_length=200)

它使用标准User类,作为Django文档建议,与用户的其他信息相关联。 有我的班级用于创建User,如何完成我的代码以创建Performer或Director?我想我应该使用success_url,但不知道如何。

from django.views.generic.edit import FormView
from django.contrib.auth.forms import UserCreationForm


class RegisterAccountFormView(FormView):
    form_class = UserCreationForm

    template_name = "accounts/registration.html"

    def form_valid(self, form):
        new_user = form.save()
        return super(RegisterAccountFormView, self).form_valid(form)

0 个答案:

没有答案