Saturday, January 1, 2011

constructor for model, automatically generate field, __init__

class Word:
fWord=models.CharField(blank=True, default='')
fsmth=models.CharField(blank=True, default='')
def __init__(self, fWord):
self.fWord=fWord
self.fsmth=fWord+fWord

I need to add entrance to fsmth automatically.
The code above gives mistakes in sites.py about Type error "classobj
is not iterable".

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment