Ilvar と Frantzdy に同意します。user_registered シグナルを使用する必要があります。以下の手順に従ってください
Forms.py
from django import forms
from registration.forms import RegistrationForm
from django.utils.translation import ugettext_lazy as _
from registration.models import RegistrationProfile
attrs_dict = { 'class': 'required' }
class RegistrationFormEx(RegistrationForm):
cell_phone = forms.CharField(widget=forms.TextInput(attrs=attrs_dict))
models.py
import hashlib
import hmac
from django.db import models
from django.contrib.auth.models import User
from registration.signals import user_registered
from userInfo.forms import RegistrationFormEx
class ExProfile(models.Model):
user = models.ForeignKey(User, unique=True)
cell_phone = models.CharField(max_length=200, blank=True)
api_key= models.CharField(max_length=200, blank=True)
def user_created(sender, user, request, **kwargs):
form = RegistrationFormEx(data=request.POST)
digest = hmac.new(str(request.POST['password1']), str(request.POST['username']), hashlib.sha256).hexdigest()
new_user = User.objects.get(username=request.POST['username'])
//here I have added api_key hash algo, you can change it
new_profile = ExProfile(user=new_user,cell_phone=request.POST['cell_phone'],api_key=digest)
new_profile.save()
return new_user
user_registered.connect(user_created)
urls.py
from django.conf.urls import patterns, include, url
import registration.backends.default.urls as regUrls
from registration.views import register
from userInfo.forms import RegistrationFormEx
urlpatterns = patterns('',
url(r'^accounts/register/$', register, {'backend': 'registration.backends.default.DefaultBackend','form_class': RegistrationFormEx}, name='registration_register'),
(r'^accounts/', include('registration.backends.default.urls'))
)
パスワードの変更を今すぐ実行できることを願っています。幸運を祈ります