list to object

39 views
Skip to first unread message

Anuj Techsmart

unread,
May 26, 2022, 10:27:37 AM5/26/22
to Django REST framework
Dear All,
I am working on rest framework api and trying to get data from two models. like this
class UserAllNFTS(viewsets.ModelViewSet):
"""
Fetchig all nfts for home page data
"""
if(UserNFTDetails.objects.filter(nft_product_status=0).exists()):
nft_image = ''
minted_nfts = []
userData = UserNFTDetails.objects.filter(nft_product_status=0)
for nftdata in userData:
#### fetching product images
userTotalInfo = UserNFTInfo.objects.get(product_id = nftdata.product_id)
product_image = userTotalInfo.product_image
#### fetching creator image & creator name
creatordata = UserRegister.objects.get(id = nftdata.user_id)
creator_name = creatordata.user_full_name
creator_image = creatordata.userimage
#### fetching total likes of products
if ProductTotalLikes.objects.filter(product_id = nftdata.product_id).exists():
pro_data = ProductTotalLikes.objects.get(product_id = nftdata.product_id)
product_total_likes = str(pro_data.total_likes)
else:
product_total_likes = 0
minted_nfts.append(
{
"nft_productID":nftdata.product_id,
"nft_title":nftdata.nft_title,
"nft_descriptions":nftdata.nft_descriptions,
"nft_collection":nftdata.nft_collection,
"nft_price":nftdata.nft_price,
"nft_royalties":nftdata.nft_royalties,
"nft_image":product_image,
"symbol": userTotalInfo.symbol,
"creator_name":creator_name,
"profile_image":'uploads/'+str(creator_image),
"total_likes":product_total_likes
}
)
serializer_class = UserSerializer

and i got error 
 assert queryset is not None, '`basename` argument not specified, and could ' \
AssertionError: `basename` argument not specified, and could not automatically determine the name from the viewset, as it does not have a `.queryset` attribute.

Please help me.
Reply all
Reply to author
Forward
0 new messages