Hi everyone. I'm quite new to python and django. I was wondering if
anyone could shed some light on this topic :

My models.py contains the classes QuestionSet and Question, which
inherits the former.
In the shell, I define a Question object as follows

q1 = Question(script = "How are you?", comment = "no comment", order =
1)


but an attempt to run q1.save() results in the following error :

>>> q1.save()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/db/models/base.py", line 435, in save
    self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/db/models/base.py", line 447, in
save_base
    using = using or router.db_for_write(self.__class__,
instance=self)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/db/utils.py", line 133, in _route_db
    return hints['instance']._state.db or DEFAULT_DB_ALIAS
AttributeError: 'Question' object has no attribute '_state'



The class definitions are :

class QuestionSet(models.Model):
    title = models.CharField(max_length=100)
    description = models.TextField()
    order = models.IntegerField()

    def __init__(self, *args, **kwargs):
        self.title = kwargs.get('title','Default Title')
        self.description = kwargs.get('description', 'DefDescription')
        self.order = kwargs.get('order', 0)


class Question(QuestionSet):
    script = models.CharField(max_length=200)
    comment = models.TextField()


    def __init__(self, *args, **kwargs):
        QuestionSet.__init__(self, args, kwargs)
        self.script = kwargs.get('script', "undefined")
        self.comment = kwargs.get('comment', "no comment")




Would greatly appreciate any suggestions

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

Reply via email to