Hi everyone, I am using django and a model definition such as
class Question(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)
Attempting to call save() on an object of the question class, causes the shell to respond with
/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'
However, removing the __init__ function, makes everything ok again. Any idea on what causes this and how to resolve it?
many thanks