【发布时间】:2018-02-05 08:02:02
【问题描述】:
在我的应用程序中运行“manage.py validate”时出现此错误。
错误:一个或多个模型未验证: ipn.paypalipn:字段“自定义”的访问器与相关字段冲突 '演员.paypalipn_set'。在定义中添加一个 related_name 参数 '风俗'。 dashboard.paypalipn:字段“自定义”的访问器与相关字段冲突 '演员.paypalipn_set'。在定义中添加一个 related_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)
在models.py中,演员
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()
【问题讨论】:
-
发布你的 models.py 文件
-
我已经编辑了我的问题,你可以看到
标签: python django python-2.7