El arquitecto
El arquitecto

Reputation: 533

Get a queryset value in Django

How can I get the value of this queryset?

I'm trying to get the value of name but it only show object.

class Brand(models.Model):
    name = models.CharField(max_length=255, blank=False)

class SubBrand(models.Model):
    name = models.CharField(max_length=255, blank=False)
    brand = models.ForeignKey(Brand)

>>> print Brand.objects.filter(subbrand__id='2')
<QuerySet [<Brand: Brand object>]>

Upvotes: 0

Views: 2383

Answers (1)

user1801517
user1801517

Reputation:

Just use index

Brand.objects.filter(subbrand__id='2')[0].name

Upvotes: 1

Related Questions