[Django]-Django-Tastypie: How Do You Access (Http)request object in the Bundle?

2๐Ÿ‘

โœ…

I just had the same problem, but found the correct answer over here:
http://groups.google.com/group/django-tastypie/tree/browse_frm/thread/801f44af3f2dbe7b/a36f303380eacf96

it seems django-tasty-pie version 0.9.9 didnโ€™t have this attribute but version 0.9.10 does!

so if you use buildout, look in to buildout.cfg
under versions:
search for django-tastypie = 0.9.9

remove this one and see what your install picks or replace it with:

django-tastypie = 0.9.10

I still have this problem, so opened a new link, see:

django-tastypie: Cannot access bundle.request in dehydrate(self,bundle)

in the question above I found out, that using 0.9.10 is not enough, version 1.0.0 beta should do the tric..

๐Ÿ‘คmichel.iamit

3๐Ÿ‘

Bundle object has request attribute.

class Bundle(object):
    """
    A small container for instances and converted data for the
    ``dehydrate/hydrate`` cycle.

    Necessary because the ``dehydrate/hydrate`` cycle needs to access data at
    different points.
    """
    def __init__(self, obj=None, data=None, request=None):
        self.obj = obj
        self.data = data or {}
        self.request = request or HttpRequest()

Anyway, you can ovveride the Resource method higher than dehydrate in the call stack.

Could you show the code?

Leave a comment