AttributeError: type object 'Product' has no attribute '_meta'

3,568 views
Skip to first unread message

yogesh gupta

unread,
Dec 1, 2015, 9:03:53 AM12/1/15
to Django users
My Models.py looks like this : 

from django.db import models

# Create your models here.
class Product(models.Model):
item_name = models.CharField(max_length=100)
item_price = models.IntegerField()
item_image = models.ImageField()

class Meta:
ordering = ['item_name']

I am getting this error : AttributeError: type object 'Product' has no attribute '_meta'       
                on giving any commands to the terminal.
pls help

Lucas Vieira May

unread,
Dec 2, 2015, 1:40:39 PM12/2/15
to Django users
try this:


from django.db import models

# Create your models here.
class Product(models.Model):
item_name = models.CharField(max_length=100)
item_price = models.IntegerField()
item_image = models.ImageField()
       
    def __unicode__(self):
return self.item_name

class Meta:
# Do not Forget the sign in front of the field
            ordering = [-'item_name']

Reply all
Reply to author
Forward
0 new messages