CharFields / Dates / Integersのみを持つdjangoモデルを返すことはできますが、ForeignKeyプロパティを持つモデルを返そうとすると、FlexのNetStatusEvent.NET_STATUSonErrorイベントハンドラーでこのエラーが発生します。
m_info Object (@16491fe9)
code "NetConnection.Call.Failed"
description "HTTP: Status 500"
details "http://127.0.0.1:8000/gateway/"
level "error"
これがmodels.pyで重要なモデルです。
class RewardActBase(models.Model):
user = models.ForeignKey(User)
start_date = models.DateTimeField(blank=True, null=True)
progress_value = models.IntegerField(default=0)
coupon_act = models.ForeignKey(CouponAct)
class Meta:
abstract = True
class ChallengeAct(RewardActBase):
challenge = models.ForeignKey(Challenge)
def __unicode__(self):
return self.challenge.title'
class CouponAct(models.Model):
coupon = models.ForeignKey(Coupon)
earned_date = models.DateTimeField(blank=True, null=True)
redeemed_date = models.DateTimeField(blank=True, null=True)
expiration_date = models.DateTimeField(blank=True, null=True)
def __unicode__(self):
return self.coupon.title
次に、pyamfを介してこれらのオブジェクトを取得する場合、これは私が使用しているメソッドであり、上記のエラーが発生します。
@login_required
def get_challenge_act(http_request, location_id):
user = http_request.user
c = ChallengeAct();
c.challenge = Challenge.objects.select_related().get(id=1)
c.start_date = datetime.now()
c.progress_value = 1
c.user = user
new_coupon_act = CouponAct()
new_coupon_act.coupon = Coupon.objects.select_related().get(id=c.challenge.coupon.id)
new_coupon_act.earned_date = datetime.now()
new_coupon_act.save()
c.coupon_act = new_coupon_act
c.save()
return c
興味深いのは、get_challenge_actメソッドを変更してChallengeActオブジェクトのプロパティを返す場合、エラーが発生しないことです。したがって、ChallengeActに属するプロパティまたはオブジェクトを返すことはできますが、ChallengeAct自体を返すことはできません。たとえば、次のコードはエラーなしでチャレンジオブジェクトを返します。
return c.challenge
では、プロパティとしてforeginkeyモデルを含むDjangoモデルを返すのに問題があるように見えますか?私は何か間違ったことをしていますか?