如何从另一个数据库扩展模型?

时间:2015-06-12 13:13:01

标签: django django-models ldap

我有两个数据库:1。在LDAP服务器上2.在我的电脑上(sqlite3)

我正在尝试扩展LDAP模型而不会干扰此数据库。

这是两个模型

1。

# LDAP_Profile_model


class LDAP_Profile(ldapdb.models.Model):

    base_dn = "dc=goldfarb,dc=corp"
    object_classes = ['user']

    username = CharField(db_column='sAMAccountName',unique=True)
    first_name = CharField(db_column='givenName')
    last_name = CharField(db_column='sn')
    full_name = CharField(db_column='cn')
    email = CharField(db_column='mail',unique=True,primary_key=True)

    def __unicode__(self):
        return u"%s (%s)" % (self.full_name,self.username)

2。

# Custom_Profile

class Custom_Profile(models.Model):
    person = models.OneToOneField(LDAP_Profile, primary_key=True)
    home_address = models.CharField(max_length=50)
    city = models.CharField(max_length=50)
    state = USStateField()
    zipcode = models.CharField(max_length=5)
    birth_date = models.DateField()

0 个答案:

没有答案