HowTo init Django model, before using it?
Posted
by mosg
on Stack Overflow
See other posts from Stack Overflow
or by mosg
Published on 2010-06-10T07:34:25Z
Indexed on
2010/06/10
7:42 UTC
Read the original article
Hit count: 324
Hi.
I'm new to python and django.
Apps | Versions:
- Python 2.6.2
- Django (working with PostgreSQL)
Question: I wrote a simple model:
class OperationType(models.Model):
eid = models.IntegerField(unique=True)
name = models.CharField(max_length=64)
def __unicode__(self):
tpl = 'eid="', str(self.eid), '" name="', self.name, '"'
return ''.join(tpl)
Now I need to initialize it, for example with this data:
0, "None"
1, "Add"
2, "Edit"
3, "Delete"
But I need to initialize this data not with admin web panel, but after class model created in the same code. How to do this?
Thanks for help!
© Stack Overflow or respective owner