In Django I created a new model:
from django.db import models
from django.contrib.auth import user
class Workers(models.Model):
user = models.OneToOneField(User, primary_key=True)
work_group = models.CharField(max_length=20)
card_num = models.IntegerField()
def __unicode__(self):
return self.user
But it doesn’t work: ImportError: cannot import name user
How to fix it?
I want to create a new table "workers" in db, which has a OneToOne relationship with table "auth_user".
You missed the models – and user is capitalized.
If you use a custom user model you should use:
More details can be found in the docs.