Python django.db.models 模块,PROTECT 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用django.db.models.PROTECT

项目:django_textformat    作者:team23    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        if args:
            kwargs['verbose_name'] = args[0]
            args = args[1:]
        kwargs.setdefault('to', 'django_textformat.TextFormat')
        kwargs.setdefault('on_delete', models.PROTECT)
        kwargs.setdefault('related_name', '+')
        kwargs.setdefault('default', 1)
        super(TextFormatField, self).__init__(*args, **kwargs)
项目:django_wagtail_boilerplate    作者:AccentDesign    | 项目源码 | 文件源码
def test_redirect_to_page(self):
        field = PageRedirection._meta.get_field('redirect_to_page')
        self.assertModelPKField(field, Page, models.PROTECT, False, False, '+')

    # view
项目:maas    作者:maas    | 项目源码 | 文件源码
def forwards(self, orm):
        # Adding model 'Space'
        db.create_table('maasserver_space', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('created', self.gf('django.db.models.fields.DateTimeField')()),
            ('updated', self.gf('django.db.models.fields.DateTimeField')()),
            ('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=256)),
        ))
        db.send_create_signal('maasserver', ['Space'])

        # Adding model 'Subnet'
        db.create_table('maasserver_subnet', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('created', self.gf('django.db.models.fields.DateTimeField')()),
            ('updated', self.gf('django.db.models.fields.DateTimeField')()),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
            ('vlan', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['maasserver.VLAN'], default=0, on_delete=models.PROTECT)),
            ('space', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['maasserver.Space'], default=0, on_delete=models.PROTECT)),
            ('cidr', self.gf('maasserver.fields.CIDRField')(unique=True)),
            ('gateway_ip', self.gf('maasserver.fields.MAASIPAddressField')(max_length=39, null=True, blank=True)),
            ('dns_servers', self.gf('djorm_pgarray.fields.ArrayField')(default={}, dbtype='text', null=True, blank=True)),
        ))
        db.send_create_signal('maasserver', ['Subnet'])

        # Adding unique constraint on 'Subnet', fields ['name', 'space']
        db.create_unique('maasserver_subnet', ['name', 'space_id'])
项目:maas    作者:maas    | 项目源码 | 文件源码
def forwards(self, orm):
        # Adding model 'Interface'
        db.create_table('maasserver_interface', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('created', self.gf('django.db.models.fields.DateTimeField')()),
            ('updated', self.gf('django.db.models.fields.DateTimeField')()),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
            ('type', self.gf('django.db.models.fields.CharField')(max_length=20)),
            ('vlan', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['maasserver.VLAN'], default=0, on_delete=models.PROTECT)),
            ('mac', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['maasserver.MACAddress'], null=True, blank=True)),
            ('ipv4_params', self.gf('maasserver.fields.JSONObjectField')(default='', blank=True)),
            ('ipv6_params', self.gf('maasserver.fields.JSONObjectField')(default='', blank=True)),
            ('params', self.gf('maasserver.fields.JSONObjectField')(default='', blank=True)),
            ('tags', self.gf('djorm_pgarray.fields.ArrayField')(default={}, dbtype='text', blank=True)),
        ))
        db.send_create_signal('maasserver', ['Interface'])

        # Adding model 'InterfaceRelationship'
        db.create_table('maasserver_interfacerelationship', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('created', self.gf('django.db.models.fields.DateTimeField')()),
            ('updated', self.gf('django.db.models.fields.DateTimeField')()),
            ('child', self.gf('django.db.models.fields.related.ForeignKey')(related_name='parent_relationships', to=orm['maasserver.Interface'])),
            ('parent', self.gf('django.db.models.fields.related.ForeignKey')(related_name='children_relationships', to=orm['maasserver.Interface'])),
        ))
        db.send_create_signal('maasserver', ['InterfaceRelationship'])

        # Adding field 'NodeGroupInterface.vlan'
        db.add_column('maasserver_nodegroupinterface', 'vlan',
                      self.gf('django.db.models.fields.related.ForeignKey')(to=orm['maasserver.VLAN'], default=0, on_delete=models.PROTECT),
                      keep_default=False)
项目:maas    作者:maas    | 项目源码 | 文件源码
def forwards(self, orm):
        # Adding field 'NodeGroupInterface.subnet'
        db.add_column('maasserver_nodegroupinterface', 'subnet',
                      self.gf('django.db.models.fields.related.ForeignKey')(to=orm['maasserver.Subnet'], null=True, on_delete=models.PROTECT, blank=True),
                      keep_default=False)