0

I have the following model class:

class ItemInstance(models.Model):

    TITLE = 0
    COLLECTION = 1
    TVSERIES = 2

This allows me to do:

item = ItemInstance.objects.all()[0]
item.TITLE ==> 0

But not this:

cls = ItemInstance
cls.TITLE ==> error

How would I enable these vars to be available for a @classmethod?

David542
  • 104,438
  • 178
  • 489
  • 842
  • 1
    What is the result of dir(ItemInstance)? I'm guessing django is doing something to mess with your class variables, because in normal python (not subclassing models.Model) that'd be fine. – CrazyCasta Jul 02 '15 at 23:57
  • That's correct -- it does work, it was actually a typo on my end. Thanks for the tip. – David542 Jul 02 '15 at 23:59
  • Everything on the subject here: http://stackoverflow.com/questions/68645/static-class-variables-in-python – demux Jul 03 '15 at 00:13

0 Answers0