invoke data from view after database operation in django

Jibin :

I have a model named "Routing_Dest_Area", i need to get the destinationId from that table and using that value I need to write another query in the same view function itself.I have written the query but don't know how to pass this value to the next query as argument.Pleaae help me to solve .

...models.py.......

class Routing_Dest_Area(models.Model):
    areaDigit = models.IntegerField(primary_key=True)
    destinationId = models.IntegerField()
    destinationName=models.CharField(max_length=30)
    def __str__(self):
        return '%d' % (self.destinationId)

class Routing_Point(models.Model):
    destinationId = models.IntegerField()
    productId=models.CharField(max_length=30)
    routingPointId= models.IntegerField()
    routingPointName=models.CharField(max_length=30)

...view.py.....

def get_route_list(request):
    data={}
    if request.method == "POST":
        areaDigit = request.POST['areaDigit']
        destination_id=Routing_Dest_Area.objects.get(areaDigit=areaDigit)
        data={'test1':Routing_Point.objects.get(destinationId=destination_id)}
    else:
        data = ''
    return render(request, 'routing/test.html',{'data':data})
ja408 :

I think what you are after is just getting the id of the query you used in destination_id, if so just add .id or .pk at the end of the query string in destination_id, Routing_Dest_Area.objects.get(areaDigit=areaDigit).id:

def get_route_list(request):
    data={}
    if request.method == "POST":
        areaDigit = request.POST['areaDigit']
        destination_id=Routing_Dest_Area.objects.get(areaDigit=areaDigit).id
        data={'test1':Routing_Point.objects.get(destinationId=destination_id)}
    else:
        data = ''
    return render(request, 'routing/test.html',{'data':data})

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=383277&siteId=1