edit - this is using Python 3.3 and Django 1.6
I don't know what I'm doing wrong here.
views.py
from django.core import serializers
from django.core.serializers import serialize
from django.http import HttpResponse
from itertools import chain
def test_queryjoin(request):
jobmstquery = Jobmst.objects.using('database1').filter(jobmst_id=3296)
jobdtlquery = Jobdtl.objects.using('database1').filter(jobdtl_id=3296)
queryset = list(chain(jobmstquery, jobdtlquery))
queryresults = serializers.serialize('python', queryset)
return HttpResponse(queryset)
But when I run it I get the following error -
'module' object has no attribute 'serialize'
on this specific line -
queryresults = serializers.serialize('python', queryset)
edit - doing the following still generates the same error -
queryresults = serializers.serialize('json', jobmstquery)
same with this -
queryresults = serializers.serialize('json', Jobmst.objects.using('database1').filter(jobmst_id = 3296))
edit - This is getting weirder... it works from shell...
from django.core import serializers
from django.core.serializers import serialize
from TidalDEV.models import Jobmst
jobmstquery = Jobmst.objects.using('database1').filter(jobmst_id=3296)
queryresults = serializers.serialize('json', jobmstquery)
print (queryresults)
Model.objects.all(). Of course, that's not a very satisfying answer if you need functions.