这link解释的过程以及和Django的登记工作1.0
这里除了上面的代码一些额外的指针。
要更新的第一个名字改变这种在models.py
def user_registered_callback(sender, user, request, **kwargs):
profile = ExUserProfile(user = user)
profile.is_human = bool(request.POST["is_human"])
user.first_name = request.POST["firstname"]
user.save()
profile.save()
user_registered.connect(user_registered_callback)
,并在forms.py文件
class ExRegistrationForm(RegistrationForm):
is_human = forms.BooleanField(label = "Are you human?:")
firstname = forms.CharField(max_length=30)
lastname = forms.CharField(max_length=30)
终于在表单上看到的变化创造一个合适的模板。该配置文件可以在管理通过创建一个在你的应用程序名为admin.py文件,并写入下面的代码
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin
from prof.models import ExUserProfile
admin.site.unregister(User)
class UserProfileInline(admin.StackedInline):
model = ExUserProfile
class UserProfileAdmin(UserAdmin):
inlines = [ UserProfileInline, ]
admin.site.register(User, UserProfileAdmin)
你有看到这个吗? http://stackoverflow.com/questions/1072270/saving-profile-with-registration-in-django-registration – rafek 2013-03-08 14:43:18
@rafek我尝试用新的自定义用户模型(在Django 1.5新) – user2054574 2013-03-08 14:45:59