Ten link wyjaśnia proces dobrze współpracuje z django rejestracji 1,0
oto kilka dodatkowych wskazówek, w uzupełnieniu do powyższego kodu.
Aby zaktualizować imię zmienić w 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)
iw pliku 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)
wreszcie zobaczyć zmiany w formularzu stworzyć odpowiedni szablon. Profil może być postrzegane w admin, tworząc plik o nazwie admin.py w swojej aplikacji i napisać następujący kod
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)
Widziałeś to? http://stackoverflow.com/questions/1072270/saving-profile-with-registration-in-django-registration – rafek
@rafek Próbuję z nowym niestandardowym modelem użytkownika (nowy w Django 1.5) – user2054574