Before I was just using the build-in django serializers and it added a model field.
{
pk: 1
model: "zoo.cat"
}
How can I get the same model field using django-piston?
I tried fields = ('id', 'model') but that didn't work.
Added this to my model:
def model(self):
return "{0}.{1}".format(self._meta.app_label, self._meta.object_name).lower()
And this to my BaseHandler:
fields = ('id', 'model')
Seems to work. If anybody has other solutions feel free to post them.
As your code for app_label
:
instance._meta.app_label
for model_name
:
instance.__class__.__name__
and with get_model
can get model name from strings or url!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With