[英]Why is it throwing an error even after migrations? (no such table: accounts_userstripe)
I'm trying to develop a website for an online store, and after creating and registering models, I don't know why, this error is thrown.我正在尝试为在线商店开发网站,并且在创建和注册模型后,我不知道为什么,会抛出此错误。 What can I do?
我能做些什么? And also after running the migrate command, it is saying no migrations to apply.
并且在运行 migrate 命令之后,它说没有要应用的迁移。 How can I do this?
我怎样才能做到这一点?
My models.py:我的模型.py:
from django.db import models
import stripe
from django.conf import settings
from django.contrib.auth.signals import user_logged_in
from django.contrib.auth.models import User
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)
Have you changed anything since your last migration?自上次迁移以来,您有什么改变吗? I think you might have changed some models, now django is unable to find your table.
我想你可能已经更换了一些型号,现在 django 无法找到你的表。
I would delete the current migration files and create new ones.我会删除当前的迁移文件并创建新的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.