我正在尝试将Stripe嵌入自定义配置文件应用程序并使用django-registration包注册用户。我需要让用户注册,然后为新用户生成条带ID,但收到以下错误:
OperationalError at /accounts/login/
no such table: profiles_userstripe
我的个人资料应用模型的完整代码如下:
from django.db import models
from django.contrib.auth.models import User
from django.contrib.auth.signals import user_logged_in
from dailydeals.stripe_info import secret_key, publish_key
import stripe
stripe.api_key = secret_key
class UserStripe(models.Model):
user = models.OneToOneField(User)
stripe_id = models.CharField(max_length=120, null=True, blank=True)
phone_number = models.CharField(max_length=120, default='000-000-0000')
def __unicode__(self):
return self.user.username
def CreateStripeID(sender, user, request, **kwargs):
new_id, created = UserStripe.objects.get_or_create(user=user)
if created:
# add users email to stripe and then set stripe id to model
stripe_cust = stripe.Customer.create(email=user.email, description = 'Customer %s was created' \
%(user.username))
print stripe_cust.id
new_id.stripe_id = stripe_cust.id
new_id.save()
else:
print "Stripe has been created %s " %new_id
#print "user logged in %s, %s, %s" %(sender, user, request)
user_logged_in.connect(CreateStripeID)
请告知。
答案 0 :(得分:0)
有点奇怪。但是,当我按照“No Such Table error”并测试数据库时,它仍然是空的。所以这次我删除了数据库,但也删除了迁移。问题是固定的,它的工作正常。