link này giải thích quá trình tốt và làm việc với django đăng ký 1,0
dưới đây là một vài gợi ý thêm, thêm vào đoạn code trên.
Để cập nhật tên đầu tiên thay đổi điều này trong 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)
và trong file 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)
cuối cùng để xem những thay đổi về hình thức tạo ra một mẫu thích hợp. Hồ sơ có thể được nhìn thấy trong quản trị viên bằng cách tạo tệp có tên admin.py trong ứng dụng của bạn và viết mã sau
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)
Bạn có thấy điều này không? http://stackoverflow.com/questions/1072270/saving-profile-with-registration-in-django-registration – rafek
@rafek Tôi thử với mô hình người dùng tùy chỉnh mới (mới ở Django 1.5) – user2054574