Saturday, January 1, 2011

Re: constructor for model, automatically generate field, __init__


On Sat, Jan 1, 2011 at 9:27 PM, gintare <g.statkute@gmail.com> wrote:

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".



maybe because you've forgotten to inherit from models.Model in the Word class definition or it's just a transcription mistake? 
 


--
Marc

--
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