Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 错误:一个或多个模型未验证,请向定义中添加相关的\u name参数_Python_Django_Python 2.7 - Fatal编程技术网

Python 错误:一个或多个模型未验证,请向定义中添加相关的\u name参数

Python 错误:一个或多个模型未验证,请向定义中添加相关的\u name参数,python,django,python-2.7,Python,Django,Python 2.7,我在应用程序中运行“manage.py validate”时遇到此错误 错误:一个或多个模型未验证: ipn.paypalipn:字段“自定义”的访问器与相关字段冲突 “演员。工资单”。将相关的_name参数添加到的定义中 “习惯”。 dashboard.paypalipn:字段“自定义”的访问者与相关字段冲突 “演员。工资单”。将相关的_name参数添加到的定义中 “习惯” 这是在Dashboard/models.py下的另一个model.py中 @csrf_exempt def show_m

我在应用程序中运行“manage.py validate”时遇到此错误

错误:一个或多个模型未验证: ipn.paypalipn:字段“自定义”的访问器与相关字段冲突 “演员。工资单”。将相关的_name参数添加到的定义中 “习惯”。 dashboard.paypalipn:字段“自定义”的访问者与相关字段冲突 “演员。工资单”。将相关的_name参数添加到的定义中 “习惯”

这是在Dashboard/models.py下的另一个model.py中

@csrf_exempt
def show_me_the_money(sender, **kwargs):

ipn_obj = sender

actor_id = ipn_obj.custom

if actor_id == "Upgrade all users!":
    User.objects.update(paid=True)

if ipn_obj.payment_status == "Completed":

    from actors.models import Actor
    from commerce.models import Transaction

    actor = Actor.objects.get(id=actor_id)

    accountdetails = actor.account_set.latest('pk')

    signupbonus = 0


    transaction = Transaction()
    transaction.actor = actor
    transaction.amount = ipn_obj.mc_gross
    transaction.currency = ipn_obj.mc_currency
    transaction.transaction_flag = 'paid'
    transaction.transaction_type = 'deposit'
    transaction.payment_method = 'Paypal'
    transaction.payment_reference = ipn_obj.txn_id
    transaction.payment_message = 'OK'
    transaction.transaction_date = timezone.now()
    transaction.UserIp = actor_ip()
    transaction.save()           

    currentamount = accountdetails.balance
    accountdetails.balance = float(signupbonus) + float(currentamount) + float(ipn_obj.mc_gross)
    accountdetails.save()

payment_was_successful.connect(show_me_the_money)
这是模特们的照片,演员

class Actor(User):

def create_actor_number():
    try:
        return int(Actor.objects.order_by('-id')[0].actor_key) + 1
    except:
        return 5001

ssn = models.CharField(max_length=32, default='', blank=True, help_text="Social security number")
address = models.OneToOneField(ActorAddress, null=True, blank=True, help_text="Actor full address information")
phone_number = models.CharField(max_length=32, default='', blank=True, help_text="Actor main phone number (Format: + and country-code eg +4670323435)")
alt_phone_number = models.CharField(max_length=32, default='', blank=True, help_text="Actor alternative phone number")
alt_email = models.EmailField(default='', blank=True, help_text="Actor alternative email")
skype = models.CharField(max_length=128, default='', blank=True, help_text="Actor Skype ID")
twitter = models.CharField(max_length=128, default='', blank=True, help_text="Actor Twitter account")
website = models.URLField(max_length=200, default='', blank=True, help_text="Actor Website URL")
blog = models.URLField(max_length=200, default='', blank=True, help_text="Actor Blog URL")   
linkedin_name = models.CharField(max_length=128, default='', blank=True, help_text="Actor LinkedIn account name") 
linkedin_ref = models.CharField(max_length=128, default='', blank=True, help_text="Actor LinkedIn reference number")
description = models.TextField(blank=True, help_text="More information about Actor")
company = models.ForeignKey(ActorCompany, null=True, blank=True)  
language = models.CharField(max_length=8, choices=LANGUAGES, default='', blank=True, help_text="Stored as ISO codes (Sv, En, etc) in the DB")
timezone = models.CharField(max_length=10, default='UTC+01:00', blank=True, help_text="UTC TimeZone <a href='http://en.wikipedia.org/wiki/Time_zone' target='_blank'>(http://en.wikipedia.org/wiki/Time_zone)</a>, eg UTC+01:00 for London")
invite_code = models.CharField(max_length=16, default='', blank=True, help_text="invite code")
updated_on = models.DateTimeField(auto_now=True, auto_now_add=True, help_text="Auto generated by system")
lockout_times = models.CharField(max_length=10, default='', blank=True, help_text="lockout times")
actor_key = models.CharField(max_length=128, default=create_actor_number, help_text="Actor unique key key used for identification")
secret_key = models.CharField(max_length=128, default=make_uuid, help_text="Actor unique secret key used to identify the Actor in API calls")
access_key = models.CharField(max_length=128, default=make_uuid, help_text="Actor unique access key used to identify the Actor in API calls")
confirmation_key = models.CharField(max_length=128, default=make_uuid, help_text="Registered user validate email")
email_confirmation = models.BooleanField(default=False, help_text="To Check if User validated email")
type = models.CharField(max_length=128, default='', blank=True, help_text="NOT IN USE")
category = models.CharField(max_length=128, default='', blank=True, help_text="NOT IN USE")
partner_status = models.BooleanField(default=False, blank=False, help_text="Describe whether the actor is partner of. If Actor is partner, True will be stored. False is the default value.")
partner_commission = models.FloatField(default=0.0, help_text="Commission percentage allocated to partner")  
partner = models.ForeignKey('actors.Actor', related_name='partner_from', limit_choices_to={"partner_status": "true"}, null=True, blank=True, help_text="This actor is connected to partner.")
#To Check if User Logged in for the first time
is_first = models.BooleanField(default=True, help_text="To Check if user logged in for the first time.")
signup_method = models.CharField(max_length=128, default='', blank=True, help_text="Determine how the user is registered in")
pkb_email = models.BooleanField(default=True, verbose_name='Send partner kickback email', help_text="To check e-mail should be sent to partner")
email_subscribed = models.BooleanField(default=True, help_text="Subscribe to notice e-mail")
sales_email = models.BooleanField(default=True, help_text="To check e-mail should be sent to seller")
is_sellerregistered = models.BooleanField(default=False, help_text="To check if user registered for seller account.")
Login_IPnumber = models.CharField(max_length=100, default='', blank=True, help_text="stores user ip when log in.")
Registration_IPnumber = models.CharField(max_length=100, default='', blank=True, help_text="stores user ip when registration.")
google_client_id = models.CharField(max_length=50, default='', blank=True, help_text="Google client ID.")
seller_commission = models.FloatField(default=-1.0, help_text="Seller commission percentage. Standard 50, 40, 30 or -1 for 0 commission")
currency = models.CharField(max_length=6, default=settings.BASE_CURRENCY, help_text="Actor's currency in ISO format")
objects = ActorManager()
类参与者(用户):
def create_actor_number():
尝试:
返回int(Actor.objects.order_by('-id')[0]。Actor_键)+1
除:
返回5001
ssn=models.CharField(最大长度=32,默认值=“”,空白值=True,帮助文本=“社会保险号”)
address=models.OneToOneField(ActorAddress,null=True,blank=True,help\u text=“演员完整地址信息”)
电话号码=models.CharField(最大长度=32,默认值=“”,空白值=True,帮助文本=“演员主电话号码(格式:+和国家代码eg+4670323435)”)
alt_phone_number=models.CharField(最大长度=32,默认值=“”,空白值=True,帮助_text=“演员备选电话号码”)
alt_email=models.EmailField(默认值为“”,空白值为True,帮助_text=“Actor alternative email”)
skype=models.CharField(最大长度=128,默认值=“”,空白值=True,帮助文本=“演员skype ID”)
twitter=models.CharField(最大长度=128,默认值=“”,空白值=True,帮助文本=“演员twitter帐户”)
website=models.URLField(最大长度=200,默认值=“”,空白值=True,帮助文本=“演员网站URL”)
blog=models.URLField(最大长度=200,默认值=“”,空白值=True,帮助文本=“演员博客URL”)
linkedin\u name=models.CharField(最大长度=128,默认值=“”,空白值=True,帮助\u text=“演员linkedin帐户名”)
linkedin\u ref=models.CharField(最大长度=128,默认值=“”,空白值=True,帮助\u text=“演员linkedin参考号”)
description=models.TextField(blank=True,help_text=“有关参与者的更多信息”)
company=models.ForeignKey(ActorCompany,null=True,blank=True)
language=models.CharField(max_length=8,choices=LANGUAGES,default='',blank=True,help_text=“存储为数据库中的ISO代码(Sv、En等))
timezone=models.CharField(最大长度=10,默认值为UTC+01:00,空白值为True,help\u text=“UTC时区,例如伦敦的UTC+01:00”)
invite_code=models.CharField(最大长度=16,默认值=“”,空白值=True,帮助_text=“invite code”)
更新了\u on=models.datetime字段(auto\u now=True,auto\u now\u add=True,help\u text=“由系统自动生成”)
锁定时间=models.CharField(最大长度=10,默认值=“”,空白值=真,帮助文本=“锁定时间”)
actor\u key=models.CharField(最大长度=128,默认值=create\u actor\u number,help\u text=“用于标识的actor唯一密钥”)
secret\u key=models.CharField(max\u length=128,default=make\u uuid,help\u text=“用于标识API调用中的参与者的唯一密钥”)
access\u key=models.CharField(max\u length=128,default=make\u uuid,help\u text=“用于标识API调用中的参与者的唯一访问键”)
确认\u key=models.CharField(最大长度=128,默认值=make\u uuid,help\u text=“注册用户验证电子邮件”)
email\u confirmation=models.BooleanField(默认值=False,help\u text=“检查用户是否验证了电子邮件”)
type=models.CharField(最大长度=128,默认值=“”,空白值=True,帮助文本=“未使用”)
category=models.CharField(最大长度=128,默认值=“”,空白值=True,帮助文本=“未使用”)
partner_status=models.BooleanField(默认值=False,blank=False,help_text=“描述参与者是否是的合作伙伴。如果参与者是合作伙伴,将存储True。False是默认值。”)
partner_commission=models.FloatField(默认值=0.0,help_text=“分配给partner的佣金百分比”)
partner=models.ForeignKey('actors.Actor',related_name='partner_from',limit_choices_to={“partner_status”:“true”},null=true,blank=true,help_text=“此Actor已连接到partner。”)
#检查用户是否首次登录
is_first=models.BooleanField(默认值=True,help_text=“检查用户是否首次登录。”)
signup\u method=models.CharField(最大长度=128,默认值=“”,blank=True,help\u text=“确定用户在中的注册方式”)
pkb_email=models.BooleanField(默认值为True,详细的_name='Send partner kickback email',help_text=“检查电子邮件应发送给合作伙伴”)
email_subscribed=models.BooleanField(默认值=True,help_text=“订阅通知电子邮件”)
sales_email=models.BooleanField(默认值=True,help_text=“检查电子邮件应发送给卖方”)
is_sellerregistered=models.BooleanField(默认值=False,help_text=“检查用户是否注册了卖家帐户。”)
Login\u IPnumber=models.CharField(最大长度=100,默认值='',blank=True,help\u text=“登录时存储用户ip。”)
注册号=models.CharField(最大长度=100,默认值=“”,空白值=True,帮助号=注册时存储用户ip。“)
google\u client\u id=models.CharField(max\u length=50,默认值为“”,blank=True,help\u text=“google client id.”)
卖方佣金=models.FloatField(默认值=-1.0,帮助文本=“卖方佣金百分比。标准50、40、30或-1表示0佣金”)
currency=models.CharField(最大长度=6,默认值=settings.BASE\u currency,help\u text=“ISO格式的演员货币”)
对象=ActorManager()

我认为您的项目有两个models.py文件,一个在dashboard目录下,另一个在ipn目录下

在这两个models.py中,您有一个名为“Paypalipn”的模型,这两个模型有一个名为“custom”的字段,其中包含相关的“Actor”模型

因此,当Django试图从“Actor”模型建立反向关系时,它们都是相同的“Actor.paypalipn_集”


因此,您需要在“自定义”字段的两个模型(dasboard/paypalipn和ipn/paypalipn)中的定义中添加“related_name”参数