Tuesday, August 19, 2014

Updating database object after a Signal is not working

So i am using django-paypal for a simple eCommerce website and my goal is to change the IPN's buyer fields to match the logged in user's registration info after a signal is received from paypal. Now I am almost there but there is something thats escaping me ... Here is the code

models.py

def view_signal(sender, **kwargs):      ipn_obj = sender      order = PayPalIPN.objects.get(txn_id=ipn_obj.txn_id) #getting the database object      user = Profile.objects.get(user=User.objects.get(username=ipn_obj.custom))  #getting the user object(when i send the info i send it with the custom field equal to the current user's username)      order.address_country = user.country #trying to change 1 field      order.save()      print order.address_country #It prints out correctly which makes me think everything is OK.        payment_was_successful.connect(view_signal)

Later when i check the field in the admin page it's still empty it hasn't change why is that?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0b4dba7f-384d-4b36-bd0d-b47f4800d8c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment