Skip to content

Instantly share code, notes, and snippets.

@bohde
Created April 14, 2011 21:15
Show Gist options
  • Save bohde/920570 to your computer and use it in GitHub Desktop.
Save bohde/920570 to your computer and use it in GitHub Desktop.
#tastypie chat log
07:10 < bedspax> uhm
07:10 < bedspax> i'm confused :)
07:16 < danielzilla> DanGer: Hard to say without seeing your code. If the template has inheritance, the context will act as a list, so you might need to try ``resp.context[-1]``.
07:16 < bedspax> danielzilla, hi
07:16 < bedspax> for my doubts, what you advice to me?
07:17 < danielzilla> bedspax: I have no clue what you're asking about.
07:18 < bedspax> i would have in the same resource this three resources, that are related to the model User: http://dpaste.com/hold/531887/
07:19 < danielzilla> I'm sorry, I don't understand. Are you trying to combine them into one resource, or just get the ``ForeignKey`` fields working.
07:20 < bedspax> ok np
07:20 < bedspax> the first
07:23 < danielzilla> bedspax: ``ModelResource`` is only designed to handle one model at a time. You can base it on one of them & add fields from the others (so that it appears to
the end user as one resource), but you'll potentially need to create ``dehydrate/hydrate`` methods to fully handle the related data.
07:24 * danielzilla heads into work.
07:24 < bedspax> ok an example of dehydrate/hidrate ?
07:26 < danielzilla> bedspax: Spend some time looking through https://github.com/toastdriven/django-tastypie/blob/master/tests/core/tests/resources.py. Works like the ``Form.clean``
variants in Django http://docs.djangoproject.com/en/1.3/ref/forms/validation/#cleaning-a-specific-field-attribute &
http://docs.djangoproject.com/en/1.3/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment