Skip to main content
The question is actually two questions asking two very distinct things. I have removed the question which does not relate to the OP question title so the answers make sense and other developers do not get confused as to what is being answered.
Source Link
Matt Seymour
  • 9.4k
  • 7
  • 64
  • 106

I get the following error message -

Exception Value: Cannot assign "(786,)": "Varmst.owner_id" must be a "Owner" instance. 

I have the following -

obj.owner_id = Owner.objects.filter(owner_name='Operations'owner_name=owner_obj).values_list('owner_id')[0] 

Problem is the value it's returning is a tuple. Specifically this -

(786,) 

All I want to return is the integer value or 786.

What am I doing wrong?

I get the following error message -

Exception Value: Cannot assign "(786,)": "Varmst.owner_id" must be a "Owner" instance. 

I have the following -

obj.owner_id = Owner.objects.filter(owner_name='Operations').values_list('owner_id')[0] 

Problem is the value it's returning is a tuple. Specifically this -

(786,) 

All I want to return is the integer value or 786.

What am I doing wrong?

I have the following -

obj.owner_id = Owner.objects.filter(owner_name=owner_obj).values_list('owner_id')[0] 

Problem is the value it's returning is a tuple. Specifically this -

(786,) 

All I want to return is the integer value or 786.

What am I doing wrong?

Source Link
whoisearth
  • 4.2k
  • 17
  • 71
  • 138

django queryset return single value

I get the following error message -

Exception Value: Cannot assign "(786,)": "Varmst.owner_id" must be a "Owner" instance. 

I have the following -

obj.owner_id = Owner.objects.filter(owner_name='Operations').values_list('owner_id')[0] 

Problem is the value it's returning is a tuple. Specifically this -

(786,) 

All I want to return is the integer value or 786.

What am I doing wrong?