userenaレシーバーを使用していますが、次のエラーが表示されます...
/accounts/signup/ での IntegrityError (1048、「列 'user_id' を null にすることはできません」)
私は自分の receivers.py でユーザーに正しくアクセスしていないと仮定しています。誰か見てもらえませんか?
ありがとう
受信者.py
from django.dispatch import receiver
from userena.signals import signup_complete
from accounts.models import Account
@receiver(signup_complete)
def handle_signup_complete(user, **kwargs):
try:
account = Account.objects.get(user=user)
except Account.DoesNotExist:
account = Account.objects.create()
account.credit_limit = 0
account.balance = 0
account.user = user
account.save()
models.py
class Account(models.Model):
OPEN, FROZEN, CLOSED = 'Open', 'Frozen', 'Closed'
status = models.CharField(max_length=32, default=OPEN)
credit_limit = models.DecimalField(max_digits=10, decimal_places=1,
null=True, blank=True)
# For performance, we keep a cached balance
balance = models.DecimalField(max_digits=10, decimal_places=1,
null=True, blank=True)
#FK
user = models.OneToOneField(User)
userena signal.py
from django.dispatch import Signal
signup_complete = Signal(providing_args=["user",])
activation_complete = Signal(providing_args=["user",])
confirmation_complete = Signal(providing_args=["user","old_email"])
password_complete = Signal(providing_args=["user",])