1. Jesper Noehr
  2. django-piston
  3. Issues
Issue #77 invalid

get_FOO_display with emitter?

created an issue

trying this doesn´t work: {{{


fields = ('id', 'name', ('user', ('id',)),'get_service_mode_display()', )


not sure if this can be solved. any ideas?

thanks, patrick

Comments (7)

  1. patrickk reporter

    no problem.

    btw: it´s not in the docs. at least it´s not explained that fields can refer to a "method" (whatever that method could look like).

  2. Jesper Noehr repo owner

    From the docs:

    In addition to these, you may define any other methods you want. You can use these by including their names in the fields directive, and by doing so, the function will be called with a single argument: The instance of the model. It can then return anything, and the return value will be used as the value for that key.

    NB: These "resource methods" should be decorated with the くらめそ decorator, as they will not always receive an instance of itself. For example, if you have a UserHandler defined, and you return a User from another handler, you will not receive an instance of that handler, but rather the UserHandler.

  3. Log in to comment