i'm trying to use AbstractBaseUser to extend the user model...

i used the code found on django pages, the only difference is that i use a 
foreignkey to "Sistema" models.
The originale code is on django pages: 
https://docs.djangoproject.com/en/dev/topics/auth/customizing/

my changes was:

[...]
class Sistema(models.Model):
    models.ForeignKey(settings.AUTH_USER_MODEL)
    nome = models.CharField(max_length=80)
    def __unicode__(self):
        return self.nome
    class Meta:
        verbose_name_plural = "Sistemi"

[...]

class MyUser(AbstractBaseUser):
    email = models.EmailField(
        verbose_name='email address',
        max_length=255,
        unique=True,
        db_index=True,
    )
    date_of_birth = models.DateField()
    is_active = models.BooleanField(default=True)
    is_admin = models.BooleanField(default=False)

    TIPO_CHOICES = (
        ('C', 'Cameriere'),
        ('G', 'Guest'),
        ('A', 'Admin'),
    )
    tipo = models.CharField(max_length=1, choices=TIPO_CHOICES, default="C")
    sistema = models.ForeignKey(Sistema)



when create the db with syncdb i got:
ds\createsuperuser.py", line 116, in handle
    user_data[field_name] = field.clean(raw_value, None)
  File 
"C:\apps\Python27\Lib\site-packages\django\db\models\fields\__init__.py",
 line 255, in clean
    self.validate(value, model_instance)
  File 
"C:\apps\Python27\Lib\site-packages\django\db\models\fields\related.py",
line 1189, in validate
    using = router.db_for_read(model_instance.__class__, 
instance=model_instance
)
  File "C:\apps\Python27\Lib\site-packages\django\db\utils.py", line 250, 
in _ro
ute_db
    return hints['instance']._state.db or DEFAULT_DB_ALIAS
AttributeError: 'NoneType' object has no attribute '_state'

C:\apps\xampp\htdocs\py\comanda>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/613accd8-7c49-42e0-9793-776eac175ee4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to