Search code examples
pythondjangodjango-piston

Django-piston: How can I get app_label + model_name?


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.


Solution

  • 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.