serialize() method included in the django Tools_booked class but while trying to access that method it shows error.
'QuerySet' object has no attribute 'serialize'
models.py
from django.core.serializers import serialize
class UpdateQuerySet(models.QuerySet):
def serialize(self):
print("*****Entered the serizlize inside the UpdateQuerySet models **********")
qs = self
return serialize('json', qs, fields=('auto_increment_id','user','component','booked'))
class UpdateManager(models.Manager):
def get_queryset(self):
return UpdateQuerySet(self.model, using=self._db)
class Tools_booked(models.Model):
auto_increment_id = models.AutoField(primary_key=True)
user=models.ForeignKey(Profile, on_delete=models.CASCADE)
component = models.CharField(max_length=30, blank=True)
booked = models.DateTimeField(auto_now_add=True,blank=True)
objects = UpdateManager()
def __str__(self):
return self.component
def serialize(self):
json_data = serialize("json", [self], fields=['auto_increment_id','user','component','booked'])
stuct = json.loads(json_data)
print(struct)
data = json.dump(stuct[0]['fields'])
return data
views.py
class SerializedDetialView(View):
def get(self, request, *args, **kwargs):
print("*****Entered the SerializedDetialView **********")
obj_list= Tools_booked.objects.filter(auto_increment_id=1)
json_data = obj_list.serialize()
return HttpResponse(json_data, content_type='application/json')
class SerializedListView(View):
def get(self, request, *args, **kwargs):
json_data = Tools_booked.objects.all().serialize()
return HttpResponse(json_data, content_type='application/json')
The error traceback
json_data = Tools_booked.objects.all().serialize()
AttributeError: 'QuerySet' object has no attribute 'serialize'
But this works.
class SerializedDetialView(View):
def get(self, request, *args, **kwargs):
obj_list= Tools_booked.objects.filter(auto_increment_id=1)
json_data = serializers.serialize("json", obj_list )
return HttpResponse(json_data, content_type='application/json')
class SerializedListView(View):
def get(self, request, *args, **kwargs):
qs = Tools_booked.objects.all()
json_data = serializers.serialize("json", qs )
return HttpResponse(json_data, content_type='application/json')
How to use the serialize() method inside the models.py ,Tools_booked class.
You should either use Django-rest frameworks serializers with many=True or use values() function of Django queryset. There is no need to write a function in models. It will work like this
class YourSerializer(serializers.ModelSerializer):
class Meta:
model = "You Model Here"
fields = "write list of your model fields here or user __all__ for all fields"
you can serialize your query like this
queryset = Your_Model.objects.all()
serialized = YourSerializer(queryset, many=True).data
Other way to do so is like this
serialized = Your_Model.objects.all().values()
This method look simple but if you are writing rest apis, you should use serializers. You can look into details of serializer here.
Here is what's working for me:
from django.core.serializers import serialize
from django.db import models
class UpdateQuerySet(models.QuerySet):
def serialize(self):
print("*****Entered the serizlize inside the UpdateQuerySet models **********")
return serialize('json', self, fields=('component','booked'))
class UpdateManager(models.Manager):
# define here methods only needed inside this manager
pass
class Tools_booked(models.Model):
component = models.CharField(max_length=30, blank=True)
booked = models.DateTimeField(auto_now_add=True,blank=True)
objects = models.Manager()
serializer = UpdateManager.from_queryset(UpdateQuerySet)()
Now you can do in your views:
json_data = Tools_booked.serializer.serialize()
I guess you have an error because your serialize method is not defined inside the manager
In your models
class UpdateManager(models.Manager):
def get_queryset(self):
return UpdateQuerySet(self.model, self._db)
# Here for you to call to your views
def serialize(self):
return self.get_queryset().serialize()
In your views
json_data = Tools_booked.objects.all().serialize()
Django has changed a little bit.
Here is this document for Django update version.
Related
models.py
class UpdateQuerySet(models.QuerySet):
def serialize(self):
qs = self
return serialize('json', qs, fields=('user', 'content', 'image'))
class UpdateManager(models.Manager):
def get_queryset(self):
return UpdateQuerySet(self.model, using=self._db)
class Tools_booked(models.Model):
auto_increment_id = models.AutoField(primary_key=True)
user=models.ForeignKey(Profile, on_delete=models.CASCADE)
component = models.CharField(max_length=30, blank=True)
booked = models.DateTimeField(auto_now_add=True,blank=True)
objects = UpdateManager()
def __str__(self):
return self.component
def serialize(self):
return serialize("json", [self], fields=['auto_increment_id','user','component','booked'])
in views.py
from django.core.serializers import serialize
class SerializedDetialView(View):
def get(self, request, *args, **kwargs):
obj = Tools_booked.objects.get(auto_increment_id=1)
json_data = obj.serialize()
return HttpResponse(json_data, content_type='application/json')
class SerializedListView(View):
def get(self, request, *args, **kwargs):
qs = Tools_booked.objects.all()
json_data = qs.serialize()
return HttpResponse(json_data, content_type='application/json')
I have seen the similar question, it is solved with a new class view. But why this code is not working. The error it showing for SerializedListView and SerializedDetialView urls is
'QuerySet' object has no attribute 'serialize'
and
'Tools_booked' object has no attribute 'serialize'
Why this error exist and how can we solve this error without creating a new class.
edit
in views.py, line 84, in get
json_data = qs.serialize()
AttributeError: 'QuerySet' object has no attribute 'serialize'
https://docs.djangoproject.com/en/3.0/topics/serialization/#serializing-data
from django.core import serializers
obj_list= Tools_booked.objects.filter(auto_increment_id=1)
json_data = serializers.serialize("json", obj_list )
return HttpResponse(json_data, content_type='application/json')
I'm trying to save a through model which has the following attributes via Django-rest-framework
when sending a POST (I'm trying to create a new instance), I get the following error:
AttributeError at /api/organisation/provider/
'EnabledExternalProvider' object has no attribute 'create'
any ideas as to what i'm doing incorrectly?
the through model in question is:
class EnabledExternalProvider(models.Model):
provider = models.ForeignKey(ExternalProvider, related_name='associatedProvider')
organisation = models.ForeignKey(Organisation, related_name='associatedOrg')
enabled = models.BooleanField(default=True)
tenantIdentifier = models.CharField('Tenant identifer for organisation', max_length = 128, null=True, blank=True)
def __str__(self):
return self.provider + '-' + self.organisation
my view is:
class EnabledExternalProvider(mixins.RetrieveModelMixin, mixins.UpdateModelMixin,generics.GenericAPIView):
serializer_class = ConnectedServiceSerializer
def get_queryset(self):
return EnabledExternalProvider.objects.filter(organisation=self.request.user.organisation_id)
def get_object(self):
queryset = self.filter_queryset(self.get_queryset())
# make sure to catch 404's below
obj = queryset.get(organisation=self.request.user.organisation_id)
self.check_object_permissions(self.request, obj)
return obj
def get(self, request, *args, **kwargs):
return self.retrieve(request, *args, **kwargs)
def post(self, request, *args, **kwargs):
return self.create(request, *args, **kwargs)
and my serializer is:
class ConnectedServiceSerializer(serializers.ModelSerializer):
provider=ExternalProviderSerializer(read_only=True)
organisation=OrganisationDetailSerializer(read_only=True)
class Meta:
model = EnabledExternalProvider
fields = ( 'organisation', 'enabled', 'tenantIdentifier')
read_only_fields = ('organisation', 'provider')
I'm POSTing the following:
{"provider":"1","tenantIdentifier":"9f0e40fe-3d6d-4172-9015-4298684a9ad2","enabled":true}
Your view doesn't have that method because you haven't defined it, or inherited from a class that has it; your mixins provide retrieve and update, but not create.
You could add mixins.CreateModelMixin to the inheritance, but at this point you should really be using a ViewSet instead.
Please consider these three models:
class Movie(models.Model):
name = models.CharField(max_length=254, unique=True)
language = models.CharField(max_length=14)
synopsis = models.TextField()
class TimeTable(models.Model):
date = models.DateField()
class Show(models.Model):
day = models.ForeignKey(TimeTable)
time = models.TimeField(choices=CHOICE_TIME)
movie = models.ForeignKey(Movie)
class Meta:
unique_together = ('day', 'time')
And each of them has their serializers:
class MovieSerializer(serializers.HyperlinkedModelSerializer):
movie_id = serializers.IntegerField(read_only=True, source="id")
class Meta:
model = Movie
fields = '__all__'
class TimeTableSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = TimeTable
fields = '__all__'
class ShowSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Show
fields = '__all__'
And their routers
router.register(r'movie-list', views.MovieViewSet)
router.register(r'time-table', views.TimeTableViewSet)
router.register(r'show-list', views.ShowViewSet)
Now I would like to get all the TimeTable objects (i.e. date list) by filtering all the Show objects by a specific movie object. This code seems to be the working and getting the list like I want it
m = Movie.objects.get(id=request_id)
TimeTable.objects.filter(show__movie=m).distinct()
But I have no clue how to use this in django rest framework? I tried doing this way (which I am pretty sure its wrong), and I am getting error:
views.py:
class DateListViewSet(viewsets.ModelViewSet, movie_id):
movie = Movie.objects.get(id=movie_id)
queryset = TimeTable.objects.filter(show__movie=movie).distinct()
serializer_class = TimeTableSerializer
urls.py:
router.register(r'date-list/(?P<movie_id>.+)/', views.DateListViewSet)
error:
class DateListViewSet(viewsets.ModelViewSet, movie_id):
NameError: name 'movie_id' is not defined
How can I filter using viewsets in django rest framework? Or if there is any other prefered way than please list it out. Thank you.
ModelViewSet by design assumes that you want to implement a CRUD(create, update, delete)
There is also a ReadOnlyModelViewSet which implements only the GET method to read only endpoints.
For Movie and Show models, a ModelViewSet or ReadOnlyModelViewSet is a good choice whether you want implement CRUD or not.
But a separate ViewSet for a related query of a TimeTable which describes a Movie model's schedule doesn't looks so good.
A better approach would be to put that endpoint to a MovieViewSet directly. DRF provided it by #detail_route and #list_route decorators.
from rest_framework.response import Response
from rest_framework.decorators import detail_route
class MovieViewSet(viewsets.ModelViewset):
queryset = Movie.objects.all()
serializer_class = MovieSerializer
#detail_route()
def date_list(self, request, pk=None):
movie = self.get_object() # retrieve an object by pk provided
schedule = TimeTable.objects.filter(show__movie=movie).distinct()
schedule_json = TimeTableSerializer(schedule, many=True)
return Response(schedule_json.data)
This endpoint will be available by a movie-list/:id/date_list url
Docs about extra routes
Register your route as
router.register(r'date-list', views.DateListViewSet)
now change your viewset as shown below,
class DateListViewSet(viewsets.ModelViewSet):
queryset = TimeTable.objects.all()
serializer_class = TimeTableSerializer
lookup_field = 'movie_id'
def retrieve(self, request, *args, **kwargs):
movie_id = kwargs.get('movie_id', None)
movie = Movie.objects.get(id=movie_id)
self.queryset = TimeTable.objects.filter(show__movie=movie).distinct()
return super(DateListViewSet, self).retrieve(request, *args, **kwargs)
Use a retrieve method, which will match any GET requests to endpoint /date-list/<id>/.
Advantage is that you don't have to explicitly handle the serialization and returning response you make ViewSet to do that hard part. We are only updating the queryset to be serialized and rest framework does the rest.
Since ModelViewSet is implemented as,
class ModelViewSet(mixins.CreateModelMixin,
mixins.RetrieveModelMixin,
mixins.UpdateModelMixin,
mixins.DestroyModelMixin,
mixins.ListModelMixin,
GenericViewSet):
"""
A viewset that provides default `create()`, `retrieve()`, `update()`,
`partial_update()`, `destroy()` and `list()` actions.
"""
pass
Its implementation includes the following methods (HTTP verb and endpoint on bracket)
list() (GET /date-list/)
create()(POST /date-list/)
retrieve()(GET date-list/<id>/)
update() (PUT /date-list/<id>/)
partial_update() (PATCH, /date-list/<id>/
destroy() (DELETE /date-list/<id>/)
If you want only to implement the retrieve() (GET requests to endpoint date-list/<id>/), you can do this instead of a `ModelViewSet),
from rest_framework import mixins, views
class DateListViewSet(mixins.RetrieveModelMixin, viewsets.GenericViewSet):
queryset = TimeTable.objects.all()
serializer_class = TimeTableSerializer
lookup_field = 'movie_id'
def retrieve(self, request, *args, **kwargs):
movie_id = kwargs.get('movie_id', None)
movie = Movie.objects.get(id=movie_id)
self.queryset = TimeTable.objects.filter(show__movie=movie).distinct()
return super(DateListViewSet, self).retrieve(request, *args, **kwargs)
The error
class DateListViewSet(viewsets.ModelViewSet, movie_id): NameError: name 'movie_id' is not defined
happens because movie_id is being passed as parent class of DataListViewSet and not as parameter as you imagined
This example in the documentation should be what you are looking for.
Adjust your URL:
url(r'date-list/(?P<movie_id>.+)/', views.DateListView.as_view())
Adjust your Model:
class Show(models.Model):
day = models.ForeignKey(TimeTable, related_name='show')
time = models.TimeField(choices=CHOICE_TIME)
movie = models.ForeignKey(Movie)
class Meta:
unique_together = ('day', 'time')
Your view would look like this:
class DateListView(generics.ListAPIView):
serializer_class = TimeTableSerializer
def get_queryset(self):
movie = Movie.objects.get(id=self.kwargs['movie_id'])
return TimeTable.objects.filter(show__movie=movie).distinct()
Another way to do it would be:
Adjust your URL:
router.register(r'date-list', views.DateListViewSet)
Adjust your Model:
class Show(models.Model):
day = models.ForeignKey(TimeTable, related_name='show')
time = models.TimeField(choices=CHOICE_TIME)
movie = models.ForeignKey(Movie)
class Meta:
unique_together = ('day', 'time')
Your view would look like this:
class DateListViewSet(viewsets.ModelViewSet):
serializer_class = TimeTableSerializer
queryset = TimeTable.objects.all()
filter_backends = (filters.DjangoFilterBackend,)
filter_fields = ('show__movie_id')
Which will allow you to make requests such as:
http://example.com/api/date-list?show__movie_id=1
See documentation
Ivan Semochkin has the correct answer but the detail decorator is deprecated. It was replaced by the action decorator.
from rest_framework.decorators import action
class MovieViewSet(viewsets.ModelViewset):
#action(detail=True)
def date_list(self, request, pk=None):
movie = self.get_object() # retrieve an object by pk provided
schedule = TimeTable.objects.filter(show__movie=movie).distinct()
schedule_json = TimeTableSerializer(schedule, many=True)
return Response(schedule_json.data)
To improve #all-is-vanity answer, you can explicitly use movie_id as a parameter in the retrieve function since you are overriding the lookup_field class property:
def retrieve(self, request, movie_id=None):
movie = Movie.objects.get(id=movie_id)
self.queryset = TimeTable.objects.filter(show__movie=movie).distinct()
return super(DateListViewSet, self).retrieve(request, *args, **kwargs)
You can also call self.get_object() to get the object:
def retrieve(self, request, movie_id=None):
movie = self.get_object()
self.queryset = TimeTable.objects.filter(show__movie=movie).distinct()
return super(DateListViewSet, self).retrieve(request, *args, **kwargs)
I find message return in google, not find.
Whats my code not post values correct?
I need help for solution correct.
As use form based generic views?
Im desenv an restAPI, i not understanding problem in my code, i running and return:
I retrieve message, flow.
views.py :
from snippets.models import Equipamento, Colaborador
from snippets.serializers import EquipamentoSerializer, ColaboradorSerializer
from rest_framework import mixins
from rest_framework import generics
class EquipamentoList(generics.ListCreateAPIView):
serializer_class = EquipamentoSerializer
def get_queryset(self):
queryset = Equipamento.objects.all()
id = self.request.query_params.get('id', None)
if id is not None:
queryset = queryset.filter(id=id)
return queryset
# class ColaboradorList(generics.CreateAPIView):
# queryset = Colaborador.objects.all()
# serializer_class = ColaboradorSerializer
# def get_queryset(self):
# queryset = Colaborador.objects.all()
# id = self.request.query_params.get('id', None)
# if id is not None:
# queryset = queryset.filter(pk=pk)
# return queryset
# def create(self, request, pk):
# queryset = Colaborador.objects.all()
# return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
# class ColaboradorDetail(generics.RetrieveUpdateDestroyAPIView):
# queryset = Colaborador.objects.all()
# serializer_class = ColaboradorSerializer
class ColaboradorList(mixins.ListModelMixin,
mixins.CreateModelMixin,
generics.GenericAPIView):
queryset = Colaborador.objects.all()
serializer_class = ColaboradorSerializer
def get(self, request, *args, **kwargs):
return self.list(request, *args, **kwargs)
def post(self, request, *args, **kwargs):
return self.create(request, *args, **kwargs)
class ColaboradorDetail(mixins.RetrieveModelMixin,
mixins.UpdateModelMixin,
mixins.DestroyModelMixin,
generics.GenericAPIView):
queryset = Colaborador.objects.all()
serializer_class = ColaboradorSerializer
def get(self, request, *args, **kwargs):
return self.retrieve(request, *args, **kwargs)
def put(self, request, *args, **kwargs):
return self.update(request, *args, **kwargs)
def delete(self, request, *args, **kwargs):
return self.destroy(request, *args, **kwargs)
serializers.py
from rest_framework import serializers
from rest_framework.validators import UniqueValidator
from snippets.models import Equipamento, Colaborador, Propriedade, MotivoParada, Apontamento
class EquipamentoSerializer(serializers.Serializer):
id = serializers.IntegerField(read_only=True)
cod_equip = serializers.IntegerField(validators=[UniqueValidator(queryset=Equipamento.objects.all())])
desc_equip = serializers.CharField(allow_blank=True, max_length=15, required=False)
def restore_object(self, attrs, instance=None):
"""
Create or update a new snippet instance, given a dictionary
of deserialized field values.
Note that if we don't define this method, then deserializing
data will simply return a dictionary of items.
"""
if instance:
# Update existing instance
instance.id = attrs.get('id', instance.id)
instance.cod_equip = attrs.get('cod_equip', instance.cod_equip)
instance.des_equip = attrs.get('desc_equip', instance.desc_equip)
return instance
# Create new instance
return Equipamento(**attrs)
class ColaboradorSerializer(serializers.Serializer):
id = serializers.IntegerField(read_only=True)
cod_colab = serializers.IntegerField(validators=[UniqueValidator(queryset=Colaborador.objects.all())])
nome_colab = serializers.CharField(max_length=30)
def restore_object(self, attrs, instance=None):
"""
Create or update a new snippet instance, given a dictionary
of deserialized field values.
Note that if we don't define this method, then deserializing
data will simply return a dictionary of items.
"""
if instance:
# Update existing instance
instance.id = attrs.get('id', instance.id)
instance.cod_colab = attrs.get('cod_colab', instance.cod_colab)
instance.nome_colab = attrs.get('nome_colab', instance.nome_colab)
return instance
# Create new instance
return Colaborador(**attrs)
class ApontamentoSerializer(serializers.Serializer):
id = serializers.IntegerField(read_only=True)
criado = serializers.DateTimeField(read_only=True)
apont_inicio = serializers.TimeField()
apont_fim = serializers.TimeField()
duracao = serializers.TimeField()
equipamento = serializers.PrimaryKeyRelatedField(queryset=Equipamento.objects.all())
colaborador = serializers.PrimaryKeyRelatedField(queryset=Colaborador.objects.all())
propriedade = serializers.PrimaryKeyRelatedField(queryset=Propriedade.objects.all())
m_parada = serializers.PrimaryKeyRelatedField(queryset=MotivoParada.objects.all())
def restore_object(self, attrs, instance=None):
"""
Create or update a new snippet instance, given a dictionary
of deserialized field values.
Note that if we don't define this method, then deserializing
data will simply return a dictionary of items.
"""
if instance:
# Update existing instance
instance.id = attrs.get('id', instance.id)
instance.criado = attrs.get('criado', instance.criado)
instance.apont_inicio = attrs.get('apont_inicio', instance.apont_inicio)
instance.apont_fim = attrs.get('apont_fim', instance.apont_fim)
instance.duracao = attrs.get('duracao', instance.duracao)
instance.equipamento = attrs.get('equipamento', instance.equipamento)
instance.colaborador = attrs.get('colaborador', instance.colaborador)
instance.propriedade = attrs.get('propriedade', instance.propriedade)
instance.m_parada = attrs.get('m_parada', instance.m_parada)
return instance
# Create new instance
return Apontamento(**attrs)
class PropriedadeSerializer(serializers.Serializer):
id = serializers.IntegerField(read_only=True)
cod_prop = serializers.IntegerField(validators=[UniqueValidator(queryset=Propriedade.objects.all())])
desc_prop = serializers.CharField(max_length=30)
def restore_object(self, attrs, instance=None):
"""
Create or update a new snippet instance, given a dictionary
of deserialized field values.
Note that if we don't define this method, then deserializing
data will simply return a dictionary of items.
"""
if instance:
# Update existing instance
instance.id = attrs.get('id', instance.id)
instance.cod_prop = attrs.get('cod_prop', instance.cod_prop)
instance.des_prop = attrs.get('desc_prop', instance.desc_prop)
return instance
# Create new instance
return Propriedade(**attrs)
class MotivoParadaSerializer(serializers.Serializer):
id = serializers.IntegerField(read_only=True)
cod_mparada = serializers.IntegerField(validators=[UniqueValidator(queryset=MotivoParada.objects.all())])
desc_mparada = serializers.CharField(max_length=30)
def restore_object(self, attrs, instance=None):
"""
Create or update a new snippet instance, given a dictionary
of deserialized field values.
Note that if we don't define this method, then deserializing
data will simply return a dictionary of items.
"""
if instance:
# Update existing instance
instance.id = attrs.get('id', instance.id)
instance.cod_mparada = attrs.get('cod_mparada', instance.cod_mparada)
instance.des_mparada = attrs.get('desc_mparada', instance.desc_mparada)
return instance
# Create new instance
return MotivoParada(**attrs)
urls.py
from django.conf.urls import url
# from snippets.views import EquipamentoList, ColaboradorList, ColaboradorDetail
from snippets import views
from rest_framework.urlpatterns import format_suffix_patterns
urlpatterns = [
# url(r'^snippets/$', views.snippet_list),
# url(r'^snippets/(?P<pk>[0-9]+)/$', views.snippet_detail),
# url('^equipamento/(?P<id>.+)/$', EquipamentoList.as_view()),
#url('^colab/(?P<id>.+)/$', ColaboradorList.as_view()),
url('^colab/$', views.ColaboradorList.as_view()),
url('^colab_add/(?P<pk>[0-9]+)/$', views.ColaboradorDetail.as_view()),
]
urlpatterns = format_suffix_patterns(urlpatterns)I find message return in google, not find solv problem?
Help.
Whats my code not post values?
I need help for solution correct.
The error message is pretty straightforward. Your serializers use the restore_object method, which is deprecated in Rest Framework 3. Either downgrade your Django Rest Framework version to 2.x, or (recommended) rewrite your code to make it compatible with Rest Framework's latest version.
I have a model class named Blueprint:
class Blueprint(models.Model):
name = models.CharField(max_length=120)
description = models.TextField()
workloads = models.CharField(choices=WORKLOAD_CHOICES)
class Meta:
ordering = ["name", ]
This model has children named workloads.
Being totally new to both, django and tastypie, I have this question:
1) Where do I execute the logic, which retrieves the list of workloads, and populates the WORKLOAD_CHOICES: in the models.py (as part of the init) or in the api.py as part of def obj_get ?
P.S. Here is the api.py:
class BlueprintResource(ModelResource):
def obj_create(self, bundle, request=None, **kwargs):
return super(BlueprintResource, self).obj_create(bundle, request)
def obj_update(self, bundle, request=None, **kwargs):
blueprint = Blueprint.objects.get(id=kwargs.get("pk"))
blueprint.description = bundle.data.get("description")
blueprint.name = bundle.data.get("name")
blueprint.workloads = bundle.data.get("workloads")
blueprint.save()
def obj_delete(self, bundle, **kwargs):
return super(BlueprintResource, self).obj_delete(bundle)
class Meta:
queryset = Blueprint.objects.all()
resource_name = 'blueprint'
authorization=Authorization()
Have a look at build_bundle() and full_dehydrate(). I haven't tested this but maybe something like this would work.
from my_app.models import WORKLOAD_CHOICES
class BlueprintResource(ModelResource):
def full_dehydrate(self, bundle, for_list=False):
dic = dict([WORKLOAD_CHOICES])
bundle.data['foo'] = self.build_bundle(data=dic)
return super(BlueprintResource, self).full_dehydrate(bundle, for_list)