S
S
Stanislav2019-05-14 16:31:20
Django
Stanislav, 2019-05-14 16:31:20

Django ORM: Query objects.all() gives error "object has no attribute 'name'"?

Greetings!
When I try to call Apparel.objects.all() or Apparel.objects.get(pk=1) I get an error

AttributeError: 'Apparel' object has no attribute 'name'

class Apparel(models.Model):
 price = models.IntegerField()
 color = models.CharField()
 ...

class ApparelSize(models.Model):
  size = models.CharField()
  apparel = models.ForeignKey(Apparel, on_delete=models.PROTECT)

class Material(models.Model):
  material = models.CharField()
  apparel = models.ForeignKey(Apparel, on_delete=models.PROTECT)

class ApparelDetail(Apparel):
  name = models.CharField()
  description = models.TextField()
  ...

All classes have data in mysql.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav, 2019-05-14
@Chebaa

Thanks for the replies, but after restarting the problem resolved itself.
If possible, please delete the question.

V
Vladimir, 2019-05-14
@vintello

ApparelDetail.objects.all()
does this line give an error?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question