Reputation: 336
I'm using django signals with post_save and receiving an instance:
@receiver(post_save, sender=ServiceOrder)
def service_order_post_save(sender, instance, created, **kwargs):
if created:
print(instance)
I just want to get all values from this instance without doing field per field (is a big Model).
I tried:
instance.objects.values()
instance.values()
list(instance)
as expected all trys failed.
Upvotes: 0
Views: 1189
Reputation: 2320
Just serialize your instance. You can try this.
from django.core import serializers
@receiver(post_save, sender=ServiceOrder)
def service_order_post_save(sender, instance, created, **kwargs):
if created:
data = serializers.serialize('json', [instance,])
print(data)
Upvotes: 1