Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion object has no attribute '_state'
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Blair Trump  
View profile  
 More options Jul 24 2012, 7:53 pm
From: Blair Trump <btr...@gmail.com>
Date: Tue, 24 Jul 2012 16:53:58 -0700 (PDT)
Local: Tues, Jul 24 2012 7:53 pm
Subject: Re: object has no attribute '_state'

Thank you!  Just also had this problem today, 24 July 2012.

Resolved now.  :)

Cheers!

On Thursday, July 12, 2012 10:30:27 AM UTC-7, aria wrote:

> Hello,

> I realize this post is from 2010, but I also had this problem as of July
> 12 2012. It's still one of the first results in a search for the error, so
> I'm posting for future googlers.

> According to the Django Model reference<https://docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs>,
> you should avoid overriding the __init__ method when inheriting from Model,
> especially if the signature changes. They recommend to instead add a custom
> manager to handle this.

> On Monday, July 5, 2010 7:51:51 PM UTC-7, jcage wrote:

>> 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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.