1

私たちの購読者は、メンバーシップから退会することはできません. トレースバック エラーから問題を見つけることができないようです (ValidationError: django.utils.functional. proxy object at 0x96d1f8c )。

これらは、プロセスで使用される関数です。

def unsubscribe_user(request, user, subscription, silent=False):
    unsubscribe_user_cron(user, subscription, silent, request)

def unsubscribe_user_cron(user, subscription, silent=False, request=None):
    subscription.current = False
    subscription.save()

これがサブスクリプション オブジェクトの作成方法です。

def subscribe_user(
    request, user, subscription_plan, gateway, reference_code, password=None):

    new_sub = Subscription.objects.create(user=user,
                                    plan=subscription_plan,
                                    start_date=start_date,
                                    end_date=end_date,
                                    first_payment_date=first_payment_date,
                                    gateway=gateway,
                                    reference_code=reference_code,
                                    current=True)

これがサブスクリプションモデルです。

class Subscription(models.Model):
    user = models.ForeignKey(User)
    plan = models.ForeignKey(SubscriptionPlan)
    start_date = models.DateTimeField(_("Start Date"))
    end_date = models.DateTimeField(_("End Date"), blank=True, null=True)    
    first_payment_date = models.DateTimeField(_("First Payment Date"))
    next_payment_date = models.DateTimeField(_("Next Payment Date"))
    status = models.CharField(_("STATUS"), blank=True, max_length=32)
    GATEWAY_CHOICES = (
        ('paypal', _('PayPal')),
        ('payflowpro', _('Payflow Pro')),
        ('cheque', _('Cheque (No gateway)')),
    )
    gateway = models.CharField(_("Ecommerce Gateway"), choices=GATEWAY_CHOICES, blank=True, max_length=20)
    reference_code = models.CharField(_("Reference Code"), blank=True, max_length=250,
        help_text=_("A reference code for the subscription. May not be necessary for all gateways"))

    # save the credit card expiry locally so we can prompt the user
    card_expiry_month = models.PositiveIntegerField(_("Card Expiry Month"), null=True, blank=True)
    card_expiry_year = models.PositiveIntegerField(_("Card Expiry Year"), null=True, blank=True)

    current = models.BooleanField(_("Is Current"), default=True)

    advance_renewal = models.BooleanField(_("Has Renewed in Advance"), default=False)

    class Meta:
        ordering = ('-start_date',)

    def save(self, *args, **kwargs):
        super(Subscription, self).save(*args, **kwargs)

登録解除機能を呼び出すスクリプトの一部

elif data['txn_type'] == "subscr_cancel":
            # User has cancelled a specific subscription
            subscription_id = data['subscr_id']            
            try:
                subscription = Subscription.objects.get(user=user,plan=subscription_plan,reference_code=subscription_id)     
                unsubscribe_user(request, user, subscription)
            except Subscription.DoesNotExist:

これは受け取ったトレースバック エラーです

Traceback (most recent call last):
  File "C:\Users\noel\Dropbox\developer\sites\rkb1\oa\ecommerce\views.py", line 97, in paypal_ipn
  File "/var/www/ninjapyjamas/oa/subscriptions/helpers.py", line 192, in unsubscribe_user
    unsubscribe_user_cron(user, subscription, silent, request)
  File "/var/www/ninjapyjamas/oa/subscriptions/helpers.py", line 206, in unsubscribe_user_cron
    subscription.save()
  File "/var/www/ninjapyjamas/oa/subscriptions/models.py", line 152, in save
    super(Subscription, self).save(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/django/db/models/base.py", line 431, in save
    self.save_base(force_insert=force_insert, force_update=force_update)
  File "/usr/lib/python2.5/site-packages/django/db/models/base.py", line 495, in save_base
    rows = manager.filter(pk=pk_val)._update(values)
  File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line 446, in _update
    query.add_update_fields(values)
  File "/usr/lib/python2.5/site-packages/django/db/models/sql/subqueries.py", line 249, in      add_update_fields
    val = field.get_db_prep_save(val)
  File "/usr/lib/python2.5/site-packages/django/db/models/fields/__init__.py", line 202, in  get_db_prep_save
    return self.get_db_prep_value(value)
  File "/usr/lib/python2.5/site-packages/django/db/models/fields/__init__.py", line 446, in get_db_prep_value
    return self.to_python(value)
  File "/usr/lib/python2.5/site-packages/django/db/models/fields/__init__.py", line 442, in to_python
    ugettext_lazy("This field cannot be null."))
ValidationError: django.utils.functional.__proxy__ object at 0x9869f2c
4

0 に答える 0