RuSs
RuSs

Reputation: 789

django int() argument must be a string or a number, not 'Liquor'

In the code bellow, I'm getting the error int() argument must be a string or a number, not 'Liquor', but I can't seem to figure out how to pass the value into the

storeID = Store.objects.get(StoreID=store_id)
storeliquor = StoreLiquor.objects.get(SPI=SPI_param)
liquor_param = storeliquor.liquorID
liquor = Liquor.objects.get(id=liquor_param)

Upvotes: 0

Views: 122

Answers (2)

Rohan
Rohan

Reputation: 53366

Actually, the liquor = Liquor.objects.get(id=liquor_param) is redundant and not needed in your case.

liquor_param or storeliquor.liquorID is the Liquor object you want to get, to retrieving it from DB again is not efficient.

Upvotes: 1

falsetru
falsetru

Reputation: 369274

It seems like liquor_param is Liquor object.

Replace the last line:

liquor = Liquor.objects.get(id=liquor_param)

with:

liquor = Liquor.objects.get(id=liquor_param.pk) # or liquor_param.id

Upvotes: 2

Related Questions