In django, how can I include some default records in my models.py?

Posted by kdt on Stack Overflow See other posts from Stack Overflow or by kdt
Published on 2010-05-02T10:55:32Z Indexed on 2010/05/02 11:27 UTC
Read the original article Hit count: 190

Filed under:
|
|

If I have a models.py like

class WidgetType(models.Model):
     name = models.CharField(max_length=200)

class Widget(models.Model):
     typeid = models.ForeignKey(WidgetType)
     data = models.CharField(max_length=200)

How can I build in a set of built in constant values for WidgetType when I know I'm only going to have a certain few types of widget? Clearly I could fire up my admin interface and add them by hand, but I'd like to simplify configuration by having it built into the python.

© Stack Overflow or respective owner

Related posts about django

Related posts about django-model