[<Object: 1>, <Object: 2>]
and
[[<Object: 1>, <Object: 2>]]
1st came from z = Model.objects.get(name=x)
This returns the object name
2nd came from z = Model.objects.filter(name=x)
The 2nd method when you look for the id
for x in z:
print(x.id)
fails with
'QuerySet' object has no attribute 'id'
also tried
zz = Model.objects.filter(name=x)
z = z.id
same result
I understand that get just gets the first singular match but so should filter as in this instance name is unique
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/c4596762-fff4-4384-9cd2-9edabb9a58f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment