Hello Angel,
Did you try the following
transaction = Transaction.objects.filter(
user=user,
status=F('detail__status'),
).first()
Best,
Simon
Le jeudi 8 mars 2018 09:52:44 UTC-5, Angel Rojas a écrit :
>
> Hello friends, I have a little problem with a relationship with 3 tables
>
> tables
> - User
> - Transaction
> - TransactionDetail
>
> my query is
>
> class TransactionInitiated(generics.ListAPIView):
> """
> List Transaction Initiated
> """
> serializer_class = TransactionSerializer
>
> def get_object(self, pk):
> user = User.objects.get(id=pk)
> transaction = Transaction.objects.filter(user_id=user.id,
> current_status=0)
> # Transactiondetail.objects.filter(transaction_id=transaction.id,
> status=0)
> return Transaction.objects.filter(user_id=user.id,
> current_status=0).order_by('-id')
>
> def get(self, request, pk, format=None):
> current_user = request.user
> list_trans_init = self.get_object(current_user.id)
> serializer = TransactionSerializer(list_trans_init, many=True)
> return JsonResponse({'data': serializer.data}, safe=False)
>
>
> with this query I recovery all user with a respective transaction, but I
> don't how to use inner join in here, I try next
>
>
> def get_object(self, pk):
> user = User.objects.get(id=pk)
> transaction = Transaction.objects.filter(user_id=user.id,
> current_status=0)
> return Transaction_Detail.objects.filter(transaction_id=transaction,
> status=0)
>
>
> in here return me the next error
>
>
> more than one row returned by a subquery used as an expression.
>
>
>
> please some help me.
>
>
> thanks for your attention.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/5b5505c0-5e15-4c35-b141-3a566cda6726%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.