is there a way to access a value of an objectvia indexing without the use of dict()?
This is my model:
class state(models.Model):
statecode = models.CharField(max_length=2, default='XX')
statename = models.CharField(max_length=32, default='XXXXXXXXXXXXX')
When I start the shell and create a new object...
>>> st=state(statecode="BO",statename="BOSTON")
...my object looks like this:
>>> st
<state: BOSTON, BO>
What I now want is to access the statename via an index, so instead of
>>> st.statename
'BOSTON'
I want to access it with something like this:
>>> st[1]
but currently I'm getting the follow error:
TypeError: 'state' object does not support indexing
Any ideas?