我正在尝试为在线商店开发一个网站,并且在创建和注册模型后,我不知道为什么,会引发此错误。我能做什么?而且,在运行migrate命令之后,它表示没有要应用的迁移。我该怎么办?
我的模型。py:
from django.db import models
import stripe
from django.conf import settings
from django.contrib.auth.signals import user_logged_in
stripe.api_key = settings.STRIPE_SECRET_KEY
class UserStripe(models.Model):
user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
stripe_id = models.CharField(max_length=120)
def __unicode__(self):
return str(self.stripe_id)
def get_or_create_stripe(sender, user, *args, **kwargs):
try:
user.userstripe.stripe_id
except UserStripe.DoesNotExist:
customer = stripe.Customer.create(
email = str(user.email)
)
new_user_stripe = UserStripe.objects.create(
user = user,
stripe_id = customer.id
)
except:
pass
user_logged_in.connect(get_or_create_stripe)