當前位置: 首頁>>代碼示例>>Python>>正文


Python db.create_unique方法代碼示例

本文整理匯總了Python中south.db.db.create_unique方法的典型用法代碼示例。如果您正苦於以下問題:Python db.create_unique方法的具體用法?Python db.create_unique怎麽用?Python db.create_unique使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在south.db.db的用法示例。


在下文中一共展示了db.create_unique方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: forwards

# 需要導入模塊: from south.db import db [as 別名]
# 或者: from south.db.db import create_unique [as 別名]
def forwards(self, orm):
        # Adding model 'Project'
        db.create_table('api_project', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
            ('organization', self.gf('django.db.models.fields.related.ForeignKey')(related_name='project_organization', to=orm['auth.User'])),
            ('created_by', self.gf('django.db.models.fields.related.ForeignKey')(related_name='project_creator', to=orm['auth.User'])),
            ('date_created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
            ('date_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)),
        ))
        db.send_create_signal('api', ['Project'])

        # Adding unique constraint on 'Project', fields ['name', 'organization']
        db.create_unique('api_project', ['name', 'organization_id'])

        # Adding M2M table for field projects on 'Team'
        db.create_table('api_team_projects', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('team', models.ForeignKey(orm['api.team'], null=False)),
            ('project', models.ForeignKey(orm['api.project'], null=False))
        ))
        db.create_unique('api_team_projects', ['team_id', 'project_id']) 
開發者ID:awemulya,項目名稱:kobo-predict,代碼行數:24,代碼來源:0002_auto__add_project__add_unique_project_name_organization.py

示例2: forwards

# 需要導入模塊: from south.db import db [as 別名]
# 或者: from south.db.db import create_unique [as 別名]
def forwards(self, orm):
        # Adding model 'Event'
        db.create_table(u'socialnetwork_event', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('event', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['backoffice.Event'])),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=10)),
            ('sn_id', self.gf('django.db.models.fields.CharField')(max_length=30)),
        ))
        db.send_create_signal(u'socialnetwork', ['Event'])

        # Adding unique constraint on 'Event', fields ['event', 'name']
        db.create_unique(u'socialnetwork_event', ['event_id', 'name'])

        # Adding model 'EventLog'
        db.create_table(u'socialnetwork_eventlog', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('eventlog', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['backoffice.EventLog'])),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=10)),
            ('sn_id', self.gf('django.db.models.fields.CharField')(max_length=30)),
        ))
        db.send_create_signal(u'socialnetwork', ['EventLog'])

        # Adding unique constraint on 'EventLog', fields ['eventlog', 'name']
        db.create_unique(u'socialnetwork_eventlog', ['eventlog_id', 'name']) 
開發者ID:Gandi,項目名稱:baobab,代碼行數:26,代碼來源:0001_initial.py

示例3: forwards

# 需要導入模塊: from south.db import db [as 別名]
# 或者: from south.db.db import create_unique [as 別名]
def forwards(self, orm):
        # Adding model 'Flowbit'
        db.create_table(u'rules_flowbit', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('set', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('isset', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('enable', self.gf('django.db.models.fields.BooleanField')(default=True)),
            ('source', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['rules.Source'])),
        ))
        db.send_create_signal(u'rules', ['Flowbit'])

        # Adding M2M table for field flowbits on 'Rule'
        m2m_table_name = db.shorten_name(u'rules_rule_flowbits')
        db.create_table(m2m_table_name, (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('rule', models.ForeignKey(orm[u'rules.rule'], null=False)),
            ('flowbit', models.ForeignKey(orm[u'rules.flowbit'], null=False))
        ))
        db.create_unique(m2m_table_name, ['rule_id', 'flowbit_id']) 
開發者ID:StamusNetworks,項目名稱:scirius,代碼行數:22,代碼來源:0006_auto__add_flowbit.py

示例4: forwards

# 需要導入模塊: from south.db import db [as 別名]
# 或者: from south.db.db import create_unique [as 別名]
def forwards(self, orm):
        # Adding model 'DashboardWidgetLastUpdate'
        db.create_table(u'dashboard_app_dashboardwidgetlastupdate', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('widget_name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=128)),
            ('last_update', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, auto_now_add=True, blank=True)),
        ))
        db.send_create_signal(u'dashboard_app', ['DashboardWidgetLastUpdate'])

        # Adding model 'DashboardWidgetSettings'
        db.create_table(u'dashboard_app_dashboardwidgetsettings', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('widget_name', self.gf('django.db.models.fields.CharField')(max_length=128)),
            ('setting_name', self.gf('django.db.models.fields.CharField')(max_length=128)),
            ('value', self.gf('django.db.models.fields.CharField')(max_length=4000)),
        ))
        db.send_create_signal(u'dashboard_app', ['DashboardWidgetSettings'])

        # Adding unique constraint on 'DashboardWidgetSettings', fields ['widget_name', 'setting_name']
        db.create_unique(u'dashboard_app_dashboardwidgetsettings', ['widget_name', 'setting_name']) 
開發者ID:bitlabstudio,項目名稱:django-dashboard-app,代碼行數:22,代碼來源:0001_initial.py

示例5: forwards

# 需要導入模塊: from south.db import db [as 別名]
# 或者: from south.db.db import create_unique [as 別名]
def forwards(self, orm):
        # Adding model 'Organization'
        db.create_table(u'crowdataapp_organization', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length='128')),
            ('description', self.gf('django.db.models.fields.TextField')()),
        ))
        db.send_create_signal(u'crowdataapp', ['Organization'])

        # Adding M2M table for field users on 'Organization'
        m2m_table_name = db.shorten_name(u'crowdataapp_organization_users')
        db.create_table(m2m_table_name, (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('organization', models.ForeignKey(orm[u'crowdataapp.organization'], null=False)),
            ('user', models.ForeignKey(orm[u'auth.user'], null=False))
        ))
        db.create_unique(m2m_table_name, ['organization_id', 'user_id'])

        # Adding field 'DocumentSetFormEntry.organization'
        db.add_column(u'crowdataapp_documentsetformentry', 'organization',
                      self.gf('django.db.models.fields.related.ForeignKey')(to=orm['crowdataapp.Organization'], null=True, blank=True),
                      keep_default=False)

        # Adding field 'UserProfile.current_organization'
        db.add_column(u'crowdataapp_userprofile', 'current_organization',
                      self.gf('django.db.models.fields.related.ForeignKey')(to=orm['crowdataapp.Organization'], null=True, blank=True),
                      keep_default=False) 
開發者ID:crowdata,項目名稱:crowdata,代碼行數:29,代碼來源:0028_auto__add_organization__add_field_documentsetformentry_organization__a.py

示例6: forwards

# 需要導入模塊: from south.db import db [as 別名]
# 或者: from south.db.db import create_unique [as 別名]
def forwards(self, orm):
        # Adding unique constraint on 'MySecondModel', fields ['name']
        db.create_unique('test_app_mysecondmodel', ['name']) 
開發者ID:plumdog,項目名稱:django_migration_testcase,代碼行數:5,代碼來源:0007_auto__add_unique_mysecondmodel_name.py

示例7: forwards

# 需要導入模塊: from south.db import db [as 別名]
# 或者: from south.db.db import create_unique [as 別名]
def forwards(self, orm):
        # Adding unique constraint on 'MetaData', fields ['xform', 'data_type', 'data_value']
        M = orm['main.metadata']
        for x in M.objects.all():
            dupes = M.objects.filter(xform_id=x.xform_id, data_type=x.data_type, data_value=x.data_value)
            if dupes.count() > 1:
                for dupe in dupes[1:]:
                    print 'Deleting duplicate MetaData', dupe.xform_id, dupe.data_type, dupe.data_value
                    dupe.delete()
            partial_dupes = M.objects.filter(xform_id=x.xform_id, data_type=x.data_type)
            if partial_dupes.count() > 1:
                print 'Partially duplicate MetaData{}'.format('\n\t'.join(map(str, partial_dupes.values_list('xform_id', 'data_type', 'data_value'))))

        db.create_unique(u'main_metadata', ['xform_id', 'data_type', 'data_value']) 
開發者ID:awemulya,項目名稱:kobo-predict,代碼行數:16,代碼來源:0012_auto__add_unique_metadata_xform_data_type_data_value.py

示例8: forwards

# 需要導入模塊: from south.db import db [as 別名]
# 或者: from south.db.db import create_unique [as 別名]
def forwards(self, orm):
        # Adding model 'ProjectXForm'
        db.create_table('api_projectxform', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('xform', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['logger.XForm'])),
            ('project', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['api.Project'])),
            ('created_by', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])),
        ))
        db.send_create_signal('api', ['ProjectXForm'])

        # Adding unique constraint on 'ProjectXForm', fields ['xform', 'project']
        db.create_unique('api_projectxform', ['xform_id', 'project_id']) 
開發者ID:awemulya,項目名稱:kobo-predict,代碼行數:14,代碼來源:0003_auto__add_projectxform__add_unique_projectxform_xform_project.py

示例9: forwards

# 需要導入模塊: from south.db import db [as 別名]
# 或者: from south.db.db import create_unique [as 別名]
def forwards(self, orm):
        # Adding M2M table for field user_stars on 'Project'
        m2m_table_name = db.shorten_name(u'api_project_user_stars')
        db.create_table(m2m_table_name, (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('project', models.ForeignKey(orm['api.project'], null=False)),
            ('user', models.ForeignKey(orm[u'auth.user'], null=False))
        ))
        db.create_unique(m2m_table_name, ['project_id', 'user_id']) 
開發者ID:awemulya,項目名稱:kobo-predict,代碼行數:11,代碼來源:0008_auto_add_user_star_field_to_project.py

示例10: forwards

# 需要導入模塊: from south.db import db [as 別名]
# 或者: from south.db.db import create_unique [as 別名]
def forwards(self, orm):

        # Changing field 'XForm.sms_id_string'
        db.alter_column('odk_logger_xform', 'sms_id_string', self.gf('django.db.models.fields.SlugField')(max_length=50))
        # Adding unique constraint on 'XForm', fields ['sms_id_string', 'user']
        db.create_unique('odk_logger_xform', ['sms_id_string', 'user_id']) 
開發者ID:awemulya,項目名稱:kobo-predict,代碼行數:8,代碼來源:0026_auto__chg_field_xform_sms_id_string__add_unique_xform_sms_id_string_us.py

示例11: forwards

# 需要導入模塊: from south.db import db [as 別名]
# 或者: from south.db.db import create_unique [as 別名]
def forwards(self, orm):
        
        # Removing unique constraint on 'XForm', fields ['id_string']
        db.delete_unique('odk_logger_xform', ['id_string'])

        # Adding unique constraint on 'XForm', fields ['id_string', 'user']
        db.create_unique('odk_logger_xform', ['id_string', 'user_id']) 
開發者ID:awemulya,項目名稱:kobo-predict,代碼行數:9,代碼來源:0002_auto__del_unique_xform_id_string__add_unique_xform_id_string_user.py

示例12: backwards

# 需要導入模塊: from south.db import db [as 別名]
# 或者: from south.db.db import create_unique [as 別名]
def backwards(self, orm):
        
        # Removing unique constraint on 'XForm', fields ['id_string', 'user']
        db.delete_unique('odk_logger_xform', ['id_string', 'user_id'])

        # Adding unique constraint on 'XForm', fields ['id_string']
        db.create_unique('odk_logger_xform', ['id_string']) 
開發者ID:awemulya,項目名稱:kobo-predict,代碼行數:9,代碼來源:0002_auto__del_unique_xform_id_string__add_unique_xform_id_string_user.py

示例13: forwards

# 需要導入模塊: from south.db import db [as 別名]
# 或者: from south.db.db import create_unique [as 別名]
def forwards(self, orm):
        
        # Adding unique constraint on 'RestService', fields ['service_url', 'name', 'xform']
        db.create_unique('restservice_restservice', ['service_url', 'name', 'xform_id']) 
開發者ID:awemulya,項目名稱:kobo-predict,代碼行數:6,代碼來源:0002_auto__add_unique_restservice_service_url_name_xform.py

示例14: forwards

# 需要導入模塊: from south.db import db [as 別名]
# 或者: from south.db.db import create_unique [as 別名]
def forwards(self, orm):
        
        # Adding unique constraint on 'Export', fields ['filename', 'xform']
        db.create_unique('odk_viewer_export', ['filename', 'xform_id']) 
開發者ID:awemulya,項目名稱:kobo-predict,代碼行數:6,代碼來源:0013_auto__add_unique_export_filename_xform.py

示例15: forwards

# 需要導入模塊: from south.db import db [as 別名]
# 或者: from south.db.db import create_unique [as 別名]
def forwards(self, orm):
        # Adding model 'MyUser'
        db.create_table(u'accounts_myuser', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('password', self.gf('django.db.models.fields.CharField')(max_length=128)),
            ('last_login', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)),
            ('is_superuser', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('first_name', self.gf('django.db.models.fields.CharField')(max_length=30, blank=True)),
            ('last_name', self.gf('django.db.models.fields.CharField')(max_length=30, blank=True)),
            ('email', self.gf('django.db.models.fields.EmailField')(unique=True, max_length=255)),
            ('is_staff', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('is_active', self.gf('django.db.models.fields.BooleanField')(default=True)),
            ('date_joined', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)),
            ('is_verified', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('date_of_birth', self.gf('django.db.models.fields.DateField')(null=True, blank=True)),
        ))
        db.send_create_signal(u'accounts', ['MyUser'])

        # Adding M2M table for field groups on 'MyUser'
        m2m_table_name = db.shorten_name(u'accounts_myuser_groups')
        db.create_table(m2m_table_name, (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('myuser', models.ForeignKey(orm[u'accounts.myuser'], null=False)),
            ('group', models.ForeignKey(orm[u'auth.group'], null=False))
        ))
        db.create_unique(m2m_table_name, ['myuser_id', 'group_id'])

        # Adding M2M table for field user_permissions on 'MyUser'
        m2m_table_name = db.shorten_name(u'accounts_myuser_user_permissions')
        db.create_table(m2m_table_name, (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('myuser', models.ForeignKey(orm[u'accounts.myuser'], null=False)),
            ('permission', models.ForeignKey(orm[u'auth.permission'], null=False))
        ))
        db.create_unique(m2m_table_name, ['myuser_id', 'permission_id']) 
開發者ID:celiao,項目名稱:django-rest-authemail,代碼行數:37,代碼來源:0001_initial.py


注:本文中的south.db.db.create_unique方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。