Mezzanine user 扩展
先按照django 官网的配置 来扩展user
比如myapp modles
from django.db import models
from django.contrib.auth.models import User
from django.contrib import admin
from django.db.models.signals import post_save
class UserProfile(models.Model):
# This field is required.
user = models.OneToOneField(User)
# Other fields here
accepted_eula = models.BooleanField()
favorite_animal = models.CharField(max_length=20, default="Dragons.")
def create_user_profile(sender, instance, created, **kwargs):
if created:
UserProfile.objects.create(user=instance)
post_save.connect(create_user_profile, sender=User)
admin.py
class UserProfileInline(admin.StackedInline):
fk_name = 'user'
model = UserProfile
# can_delete = False
# verbose_name_plural = 'profile'
# Define a new User admin
class UserAdmin(UserAdmin):
inlines = (UserProfileInline, )
# Re-register UserAdmin
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
settings中
AUTH_PROFILE_MODULE = 'accounts.UserProfile'
最后 开启mezz的accounts功能 即可完成。
补充:综合编程 , 其他综合 ,