django.db.models.AutoField - python examples

Here are the examples of the python api django.db.models.AutoField taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

60 Examples 7

3 View Complete Implementation : test_custom_fields.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_none_column(self):
        clast NoColumnField(models.AutoField):
            def db_type(self, connection):
                # None indicates not to create a column in the database.
                return None

        clast Model(models.Model):
            field = NoColumnField(primary_key=True, db_column="other_field")
            other_field = models.IntegerField()

        field = Model._meta.get_field('field')
        self.astertEqual(field.check(), [])

3 View Complete Implementation : 0137_auto__add_field_organizationmember_has_global_access.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : NetEaseGame
    def forwards(self, orm):
        # Adding field 'OrganizationMember.has_global_access'
        db.add_column('sentry_organizationmember', 'has_global_access',
                      self.gf('django.db.models.fields.BooleanField')(default=True),
                      keep_default=False)

        # Adding M2M table for field teams on 'OrganizationMember'
        m2m_table_name = db.shorten_name('sentry_organizationmember_teams')
        db.create_table(m2m_table_name, (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('organizationmember', self.gf('sentry.db.models.fields.FlexibleForeignKey')(orm['sentry.organizationmember'], null=False)),
            ('team', self.gf('sentry.db.models.fields.FlexibleForeignKey')(orm['sentry.team'], null=False))
        ))
        db.create_unique(m2m_table_name, ['organizationmember_id', 'team_id'])

3 View Complete Implementation : inspectors.py
Copyright Apache License 2.0
Author : BeanWei
def get_pk_description(model, model_field):
    if isinstance(model_field, models.AutoField):
        value_type = _('unique integer value')
    elif isinstance(model_field, models.UUIDField):
        value_type = _('UUID string')
    else:
        value_type = _('unique value')

    return _('A {value_type} identifying this {name}.').format(
        value_type=value_type,
        name=model._meta.verbose_name,
    )

3 View Complete Implementation : 0014_M2M_pictures_article.py
Copyright GNU General Public License v3.0
Author : CodigoSur
    def forwards(self, orm):
        # Adding M2M table for field pictures on 'Article'
        db.create_table('articles_article_pictures', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('article', models.ForeignKey(orm['articles.article'], null=False)),
            ('picture', models.ForeignKey(orm['medialibrary.picture'], null=False))
        ))
        db.create_unique('articles_article_pictures', ['article_id', 'picture_id'])

3 View Complete Implementation : db.py
Copyright Apache License 2.0
Author : edisonlz
    def test_make_added_foreign_key_not_null(self):
        # Table for FK to target
        User = db.mock_model(model_name='User', db_table='auth_user', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
        # Table with no foreign key
        db.create_table("test_fk", [
            ('eggs', models.IntegerField()),
        ])
        db.execute_deferred_sql()
        
        # Add foreign key
        db.add_column("test_fk", 'foreik', models.ForeignKey(User, null=True),
                      keep_default = False)
        db.execute_deferred_sql()
        
        # Make the FK null
        db.alter_column("test_fk", "foreik_id", models.ForeignKey(User))
        db.execute_deferred_sql()

3 View Complete Implementation : converter.py
Copyright MIT License
Author : eamigo86
@convert_django_field.register(models.AutoField)
def convert_field_to_id(field, registry=None, input_flag=None, nested_field=False):
    if input_flag:
        return ID(
            description=field.help_text or "Django object unique identification field",
            required=input_flag == "update",
        )
    return ID(
        description=field.help_text or "Django object unique identification field",
        required=not field.null,
    )

3 View Complete Implementation : 0014_auto.py
Copyright GNU General Public License v3.0
Author : CodigoSur
    def forwards(self, orm):
        
        # Adding M2M table for field rss_content_types on 'SiteSettings'
        db.create_table('cyclope_sitesettings_rss_content_types', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('sitesettings', models.ForeignKey(orm['cyclope.sitesettings'], null=False)),
            ('contenttype', models.ForeignKey(orm['contenttypes.contenttype'], null=False))
        ))
        db.create_unique('cyclope_sitesettings_rss_content_types', ['sitesettings_id', 'contenttype_id'])

3 View Complete Implementation : 0003_auto__del_field_author_country__add_field_author_image__add_field_auth.py
Copyright GNU General Public License v3.0
Author : CodigoSur
    def forwards(self, orm):

        # Rename field 'Author.country' to 'Author.origin'
        db.rename_column('cyclope_author', 'country', 'origin')

        # Adding field 'Author.image'
        db.add_column('cyclope_author', 'image', self.gf('filebrowser.fields.FileBrowseField')(default='', max_length=100, blank=True), keep_default=False)

        # Adding M2M table for field content_types on 'Author'
        db.create_table('cyclope_author_content_types', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('author', models.ForeignKey(orm['cyclope.author'], null=False)),
            ('contenttype', models.ForeignKey(orm['contenttypes.contenttype'], null=False))
        ))
        db.create_unique('cyclope_author_content_types', ['author_id', 'contenttype_id'])

3 View Complete Implementation : db.py
Copyright Apache License 2.0
Author : edisonlz
    def test_foreign_keys(self):
        """
        Tests foreign key creation, especially uppercase (see #61)
        """
        Test = db.mock_model(model_name='Test', db_table='test5a',
                             db_tablespace='', pk_field_name='ID',
                             pk_field_type=models.AutoField, pk_field_args=[])
        db.create_table("test5a", [('ID', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True))])
        db.create_table("test5b", [
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('UNIQUE', models.ForeignKey(Test)),
        ])
        db.execute_deferred_sql()

3 View Complete Implementation : batch.py
Copyright Apache License 2.0
Author : BeanWei
    def change_models(self, queryset, cleaned_data):
        n = queryset.count()

        data = {}
        fields = self.opts.fields + self.opts.many_to_many
        for f in fields:
            if not f.editable or isinstance(f, models.AutoField) \
                    or not f.name in cleaned_data:
                continue
            data[f] = cleaned_data[f.name]

        if n:
            for obj in queryset:
                for f, v in data.items():
                    f.save_form_data(obj, v)
                obj.save()
            self.message_user(_("Successfully change %(count)d %(items)s.") % {
                "count": n, "items": model_ngettext(self.opts, n)
            }, 'success')

3 View Complete Implementation : db.py
Copyright Apache License 2.0
Author : edisonlz
    @skipUnless(db.supports_foreign_keys, 'Foreign keys can only be deleted on '
                                          'engines that support them.')
    def test_recursive_foreign_key_delete(self):
        """
        Test that recursive foreign keys are deleted correctly (see #1065)
        """
        Test = db.mock_model(model_name='Test', db_table='test_rec_fk_del',
                             db_tablespace='', pk_field_name='id',
                             pk_field_type=models.AutoField, pk_field_args=[])
        db.create_table('test_rec_fk_del', [
            ('id', models.AutoField(primary_key=True, auto_created=True)),
            ('fk', models.ForeignKey(Test)),
        ])
        db.execute_deferred_sql()
        db.delete_foreign_key('test_rec_fk_del', 'fk_id')

3 View Complete Implementation : db_mysql.py
Copyright Apache License 2.0
Author : edisonlz
    def _create_foreign_tables(self, main_name, reference_name):
        # Create foreign table and model
        Foreign = db.mock_model(model_name='Foreign', db_table=reference_name,
                                db_tablespace='', pk_field_name='id',
                                pk_field_type=models.AutoField,
                                pk_field_args=[])
        db.create_table(reference_name, [
                ('id', models.AutoField(primary_key=True)),
            ])
        # Create table with foreign key
        db.create_table(main_name, [
                ('id', models.AutoField(primary_key=True)),
                ('foreign', models.ForeignKey(Foreign)),
            ])
        return Foreign

3 View Complete Implementation : fields.py
Copyright GNU Lesser General Public License v3.0
Author : 007gzs
def formfield(field, **kwargs):
    kwargs.setdefault('validators', field.validators)
    if isinstance(field, (
            models.AutoField,
            models.PositiveIntegerField,
            models.PositiveSmallIntegerField)):
        return fields.IntegerField(min_value=0, **kwargs)
    else:
        return globals().get(field.get_internal_type(), fields.CharField)(**kwargs)

3 View Complete Implementation : 0002_eggs.py
Copyright Apache License 2.0
Author : edisonlz
    def forwards(self):
        
        Spam = db.mock_model(model_name='Spam', db_table='southtest_spam', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField)
        
        db.create_table("southtest_eggs", (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('size', models.FloatField()),
            ('quansaty', models.IntegerField()),
            ('spam', models.ForeignKey(Spam)),
        ))

3 View Complete Implementation : 0030_auto__add_view__chg_field_event_group.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : NetEaseGame
    def forwards(self, orm):

        # Adding model 'View'
        db.create_table('sentry_view', (
            ('id', self.gf('sentry.db.models.fields.bounded.BoundedBigAutoField')(primary_key=True)),
            ('path', self.gf('django.db.models.fields.CharField')(unique=True, max_length=100)),
        ))
        db.send_create_signal('sentry', ['View'])

        # Adding M2M table for field views on 'Group'
        db.create_table('sentry_groupedmessage_views', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('group', self.gf('sentry.db.models.fields.FlexibleForeignKey')(orm['sentry.group'], null=False)),
            ('view', self.gf('sentry.db.models.fields.FlexibleForeignKey')(orm['sentry.view'], null=False))
        ))
        db.create_unique('sentry_groupedmessage_views', ['group_id', 'view_id'])

3 View Complete Implementation : test_operations.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def set_up_test_model(self, force_raster_creation=False):
        test_fields = [
            ('id', models.AutoField(primary_key=True)),
            ('name', models.CharField(max_length=100, unique=True)),
            ('geom', fields.MultiPolygonField(srid=4326))
        ]
        if connection.features.supports_raster or force_raster_creation:
            test_fields += [('rast', fields.RasterField(srid=4326, null=True))]
        operations = [migrations.CreateModel('Neighborhood', test_fields)]
        self.current_state = self.apply_operations('gis', ProjectState(), operations)

3 View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_auto_field(self):
        field = models.AutoField(primary_key=True)
        field.set_attributes_from_name("id")
        name, path, args, kwargs = field.deconstruct()
        self.astertEqual(path, "django.db.models.AutoField")
        self.astertEqual(args, [])
        self.astertEqual(kwargs, {"primary_key": True})

3 View Complete Implementation : test_cast.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_cast_to_integer(self):
        for field_clast in (
            models.AutoField,
            models.BigAutoField,
            models.IntegerField,
            models.BigIntegerField,
            models.SmallIntegerField,
            models.PositiveIntegerField,
            models.PositiveSmallIntegerField,
        ):
            with self.subTest(field_clast=field_clast):
                numbers = Author.objects.annotate(cast_int=Cast('alias', field_clast()))
                self.astertEqual(numbers.get().cast_int, 1)

3 View Complete Implementation : 0005_del_article__pictures.py
Copyright GNU General Public License v3.0
Author : CodigoSur
    def backwards(self, orm):

        # Adding M2M table for field pictures on 'Article'
        db.create_table('articles_article_pictures', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('article', models.ForeignKey(orm['articles.article'], null=False)),
            ('picture', models.ForeignKey(orm['medialibrary.picture'], null=False))
        ))
        db.create_unique('articles_article_pictures', ['article_id', 'picture_id'])

3 View Complete Implementation : 0066_auto__del_view.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : NetEaseGame
    def backwards(self, orm):
        # Adding model 'View'
        db.create_table('sentry_view', (
            ('path', self.gf('django.db.models.fields.CharField')(max_length=100, unique=True)),
            ('verbose_name', self.gf('django.db.models.fields.CharField')(max_length=200, null=True)),
            ('id', self.gf('sentry.db.models.fields.bounded.BoundedBigAutoField')(primary_key=True)),
            ('verbose_name_plural', self.gf('django.db.models.fields.CharField')(max_length=200, null=True)),
        ))
        db.send_create_signal('sentry', ['View'])

        # Adding M2M table for field views on 'Group'
        db.create_table('sentry_groupedmessage_views', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('group', self.gf('sentry.db.models.fields.FlexibleForeignKey')(orm['sentry.group'], null=False)),
            ('view', self.gf('sentry.db.models.fields.FlexibleForeignKey')(orm['sentry.view'], null=False))
        ))
        db.create_unique('sentry_groupedmessage_views', ['group_id', 'view_id'])

3 View Complete Implementation : 0008_auto_add_user_star_field_to_project.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
    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'])

3 View Complete Implementation : 0160_auto__add_field_authprovider_default_global_access.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : NetEaseGame
    def forwards(self, orm):
        # Adding field 'AuthProvider.default_global_access'
        db.add_column('sentry_authprovider', 'default_global_access',
                      self.gf('django.db.models.fields.BooleanField')(default=True),
                      keep_default=False)

        # Adding M2M table for field default_teams on 'AuthProvider'
        m2m_table_name = db.shorten_name('sentry_authprovider_default_teams')
        db.create_table(m2m_table_name, (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('authprovider', FlexibleForeignKey(orm['sentry.authprovider'], null=False)),
            ('team', FlexibleForeignKey(orm['sentry.team'], null=False))
        ))
        db.create_unique(m2m_table_name, ['authprovider_id', 'team_id'])

3 View Complete Implementation : utils.py
Copyright Apache License 2.0
Author : BeanWei
def get_all_model_fields(model):
    opts = model._meta

    return [
        f.name for f in sorted(opts.fields + opts.many_to_many)
        if not isinstance(f, models.AutoField) and
        not (getattr(remote_field(f), 'parent_link', False))
    ]

3 View Complete Implementation : 0001_spam.py
Copyright Apache License 2.0
Author : edisonlz
    def forwards(self):
        # Model 'Spam'
        db.create_table("southtest_spam", (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('weight', models.FloatField()),
            ('expires', models.DateTimeField()),
            ('name', models.CharField(max_length=255))
        ))

0 View Complete Implementation : introspection.py
Copyright MIT License
Author : bpgc-cte
    def sequence_list(self):
        "Returns a list of information about all DB sequences for all models in all apps."
        from django.apps import apps
        from django.db import models, router

        sequence_list = []

        for app_config in apps.get_app_configs():
            for model in router.get_migratable_models(app_config, self.connection.alias):
                if not model._meta.managed:
                    continue
                if model._meta.swapped:
                    continue
                for f in model._meta.local_fields:
                    if isinstance(f, models.AutoField):
                        sequence_list.append({'table': model._meta.db_table, 'column': f.column})
                        break  # Only one AutoField is allowed per model, so don't bother continuing.

                for f in model._meta.local_many_to_many:
                    # If this is an m2m using an intermediate table,
                    # we don't need to reset the sequence.
                    if f.remote_field.through is None:
                        sequence_list.append({'table': f.m2m_db_table(), 'column': None})

        return sequence_list

0 View Complete Implementation : operations.py
Copyright MIT License
Author : bpgc-cte
    def sequence_reset_sql(self, style, model_list):
        from django.db import models
        output = []
        query = self._sequence_reset_sql
        for model in model_list:
            for f in model._meta.local_fields:
                if isinstance(f, models.AutoField):
                    table_name = self.quote_name(model._meta.db_table)
                    sequence_name = self._get_sequence_name(model._meta.db_table)
                    column_name = self.quote_name(f.column)
                    output.append(query % {'sequence': sequence_name,
                                           'table': table_name,
                                           'column': column_name})
                    # Only one AutoField is allowed per model, so don't
                    # continue to loop
                    break
            for f in model._meta.many_to_many:
                if not f.remote_field.through:
                    table_name = self.quote_name(f.m2m_db_table())
                    sequence_name = self._get_sequence_name(f.m2m_db_table())
                    column_name = self.quote_name('id')
                    output.append(query % {'sequence': sequence_name,
                                           'table': table_name,
                                           'column': column_name})
        return output

0 View Complete Implementation : operations.py
Copyright MIT License
Author : bpgc-cte
    def sequence_reset_sql(self, style, model_list):
        from django.db import models
        output = []
        qn = self.quote_name
        for model in model_list:
            # Use `coalesce` to set the sequence for each model to the max pk value if there are records,
            # or 1 if there are none. Set the `is_called` property (the third argument to `setval`) to true
            # if there are records (as the max pk value is already in use), otherwise set it to false.
            # Use pg_get_serial_sequence to get the underlying sequence name from the table name
            # and column name (available since PostgreSQL 8)

            for f in model._meta.local_fields:
                if isinstance(f, models.AutoField):
                    output.append(
                        "%s setval(pg_get_serial_sequence('%s','%s'), "
                        "coalesce(max(%s), 1), max(%s) %s null) %s %s;" % (
                            style.SQL_KEYWORD('SELECT'),
                            style.SQL_TABLE(qn(model._meta.db_table)),
                            style.SQL_FIELD(f.column),
                            style.SQL_FIELD(qn(f.column)),
                            style.SQL_FIELD(qn(f.column)),
                            style.SQL_KEYWORD('IS NOT'),
                            style.SQL_KEYWORD('FROM'),
                            style.SQL_TABLE(qn(model._meta.db_table)),
                        )
                    )
                    break  # Only one AutoField is allowed per model, so don't bother continuing.
            for f in model._meta.many_to_many:
                if not f.remote_field.through:
                    output.append(
                        "%s setval(pg_get_serial_sequence('%s','%s'), "
                        "coalesce(max(%s), 1), max(%s) %s null) %s %s;" % (
                            style.SQL_KEYWORD('SELECT'),
                            style.SQL_TABLE(qn(f.m2m_db_table())),
                            style.SQL_FIELD('id'),
                            style.SQL_FIELD(qn('id')),
                            style.SQL_FIELD(qn('id')),
                            style.SQL_KEYWORD('IS NOT'),
                            style.SQL_KEYWORD('FROM'),
                            style.SQL_TABLE(qn(f.m2m_db_table()))
                        )
                    )
        return output

0 View Complete Implementation : models.py
Copyright GNU General Public License v2.0
Author : blackye
def construct_instance(form, instance, fields=None, exclude=None):
    """
    Constructs and returns a model instance from the bound ``form``'s
    ``cleaned_data``, but does not save the returned instance to the
    database.
    """
    from django.db import models
    opts = instance._meta

    cleaned_data = form.cleaned_data
    file_field_list = []
    for f in opts.fields:
        if not f.editable or isinstance(f, models.AutoField) \
                or not f.name in cleaned_data:
            continue
        if fields is not None and f.name not in fields:
            continue
        if exclude and f.name in exclude:
            continue
        # Defer saving file-type fields until after the other fields, so a
        # callable upload_to can use the values from other fields.
        if isinstance(f, models.FileField):
            file_field_list.append(f)
        else:
            f.save_form_data(instance, cleaned_data[f.name])

    for f in file_field_list:
        f.save_form_data(instance, cleaned_data[f.name])

    return instance

0 View Complete Implementation : 0001_initial.py
Copyright GNU General Public License v3.0
Author : CodigoSur
    def forwards(self, orm):
        
        # Adding model 'Poll'
        db.create_table('polls_poll', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=250, db_index=True)),
            ('slug', self.gf('autoslug.fields.AutoSlugField')(unique=True, max_length=50, populate_from=None, unique_with=(), db_index=True)),

            ('published', self.gf('django.db.models.fields.BooleanField')(default=True)),
            ('description', self.gf('django.db.models.fields.TextField')(blank=True)),
        ))
        db.send_create_signal('polls', ['Poll'])

        # Adding model 'Question'
        db.create_table('polls_question', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('poll', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['polls.Poll'])),
            ('text', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)),
            ('order', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True)),
            ('allow_multiple_answers', self.gf('django.db.models.fields.BooleanField')(default=False)),
        ))
        db.send_create_signal('polls', ['Question'])

        # Adding model 'Answer'
        db.create_table('polls_answer', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('question', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['polls.Question'])),
            ('text', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)),
        ))
        db.send_create_signal('polls', ['Answer'])

        # Adding model 'Submission'
        db.create_table('polls_submission', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('poll', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['polls.Poll'])),
            ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True)),
            ('foreign_user', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=60, blank=True)),
        ))
        db.send_create_signal('polls', ['Submission'])

        # Adding M2M table for field answers on 'Submission'
        db.create_table('polls_submission_answers', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('submission', models.ForeignKey(orm['polls.submission'], null=False)),
            ('answer', models.ForeignKey(orm['polls.answer'], null=False))
        ))
        db.create_unique('polls_submission_answers', ['submission_id', 'answer_id'])

0 View Complete Implementation : 0001_initial.py
Copyright GNU General Public License v3.0
Author : CodigoSur
    def forwards(self, orm):

        # Adding model 'Collection'
        db.create_table('collections_collection', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=50)),
            ('slug', self.gf('autoslug.fields.AutoSlugField')(unique_with=(), max_length=50, populate_from=None, db_index=True)),
            ('visible', self.gf('django.db.models.fields.BooleanField')(default=True, blank=True)),
            ('navigation_root', self.gf('django.db.models.fields.BooleanField')(default=False, blank=True)),
            ('description', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
            ('image', self.gf('filebrowser.fields.FileBrowseField')(max_length=250, blank=True)),
        ))
        db.send_create_signal('collections', ['Collection'])

        # Adding M2M table for field content_types on 'Collection'
        db.create_table('collections_collection_content_types', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('collection', models.ForeignKey(orm['collections.collection'], null=False)),
            ('contenttype', models.ForeignKey(orm['contenttypes.contenttype'], null=False))
        ))
        db.create_unique('collections_collection_content_types', ['collection_id', 'contenttype_id'])

        # Adding model 'Category'
        db.create_table('collections_category', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('collection', self.gf('django.db.models.fields.related.ForeignKey')(related_name=u'collection categories', to=orm['collections.Collection'])),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=50)),
            ('slug', self.gf('autoslug.fields.AutoSlugField')(unique_with=(), max_length=50, populate_from=None, db_index=True)),
            ('parent', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name=u'children', null=True, to=orm['collections.Category'])),
            ('active', self.gf('django.db.models.fields.BooleanField')(default=True, db_index=True, blank=True)),
            ('description', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
            ('image', self.gf('filebrowser.fields.FileBrowseField')(max_length=250, blank=True)),
            ('lft', self.gf('django.db.models.fields.PositiveIntegerField')(db_index=True)),
            ('rght', self.gf('django.db.models.fields.PositiveIntegerField')(db_index=True)),
            ('tree_id', self.gf('django.db.models.fields.PositiveIntegerField')(db_index=True)),
            ('level', self.gf('django.db.models.fields.PositiveIntegerField')(db_index=True)),
        ))
        db.send_create_signal('collections', ['Category'])

        # Adding unique constraint on 'Category', fields ['collection', 'name']
        db.create_unique('collections_category', ['collection_id', 'name'])

        # Adding model 'CategoryMap'
        db.create_table('collections_categorymap', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('category', self.gf('django.db.models.fields.related.ForeignKey')(related_name='category_maps', to=orm['collections.Category'])),
            ('content_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['contenttypes.ContentType'])),
            ('object_id', self.gf('django.db.models.fields.PositiveIntegerField')(db_index=True)),
        ))
        db.send_create_signal('collections', ['CategoryMap'])

0 View Complete Implementation : 0001_initial.py
Copyright Apache License 2.0
Author : edisonlz
    def forwards(self, orm):
        # Adding model 'User'
        db.create_table(u'user_user', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('pastword', 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)),
            ('username', self.gf('django.db.models.fields.CharField')(unique=True, max_length=30)),
            ('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')(max_length=75, blank=True)),
            ('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)),
            ('role', self.gf('django.db.models.fields.IntegerField')(default=1)),
        ))
        db.send_create_signal('user', ['User'])

        # Adding M2M table for field groups on 'User'
        db.create_table(u'user_user_groups', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('user', models.ForeignKey(orm['user.user'], null=False)),
            ('group', models.ForeignKey(orm[u'auth.group'], null=False))
        ))
        db.create_unique(u'user_user_groups', ['user_id', 'group_id'])

        # Adding M2M table for field user_permissions on 'User'
        db.create_table(u'user_user_user_permissions', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('user', models.ForeignKey(orm['user.user'], null=False)),
            ('permission', models.ForeignKey(orm[u'auth.permission'], null=False))
        ))
        db.create_unique(u'user_user_user_permissions', ['user_id', 'permission_id'])

        # Adding model 'UserBoxPerm'
        db.create_table(u'user_userboxperm', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['user.User'])),
            ('drawer_id', self.gf('django.db.models.fields.IntegerField')()),
            ('source', self.gf('django.db.models.fields.IntegerField')(default=0)),
        ))
        db.send_create_signal('user', ['UserBoxPerm'])

0 View Complete Implementation : 0001_initial.py
Copyright GNU General Public License v3.0
Author : CodigoSur
    def forwards(self, orm):

        # Adding model 'Author'
        db.create_table('articles_author', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=250, db_index=True)),
            ('slug', self.gf('autoslug.fields.AutoSlugField')(unique=True, max_length=50, populate_from=None, unique_with=(), db_index=True)),
            ('country', self.gf('django.db.models.fields.CharField')(default='', max_length=250, db_index=True, blank=True)),
            ('notes', self.gf('django.db.models.fields.TextField')(default='', blank=True)),
        ))
        db.send_create_signal('articles', ['Author'])

        # Adding model 'Source'
        db.create_table('articles_source', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=250, db_index=True)),
            ('slug', self.gf('autoslug.fields.AutoSlugField')(unique=True, max_length=50, populate_from=None, unique_with=(), db_index=True)),
            ('link', self.gf('django.db.models.fields.CharField')(default='', max_length=250, blank=True)),
        ))
        db.send_create_signal('articles', ['Source'])

        # Adding model 'Article'
        db.create_table('articles_article', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=250, db_index=True)),
            ('slug', self.gf('autoslug.fields.AutoSlugField')(unique=True, max_length=50, populate_from=None, unique_with=(), db_index=True)),
            ('published', self.gf('django.db.models.fields.BooleanField')(default=True, blank=True)),
            ('presatle', self.gf('django.db.models.fields.CharField')(max_length=250, blank=True)),
            ('summary', self.gf('django.db.models.fields.TextField')(blank=True)),
            ('text', self.gf('django.db.models.fields.TextField')()),
            ('author', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['articles.Author'])),
            ('source', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['articles.Source'], null=True, blank=True)),
            ('creation_date', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
            ('date', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
            ('allow_comments', self.gf('django.db.models.fields.CharField')(default='SITE', max_length=4)),
        ))
        db.send_create_signal('articles', ['Article'])

        # Adding M2M table for field pictures on 'Article'
        db.create_table('articles_article_pictures', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('article', models.ForeignKey(orm['articles.article'], null=False)),
            ('picture', models.ForeignKey(orm['medialibrary.picture'], null=False))
        ))
        db.create_unique('articles_article_pictures', ['article_id', 'picture_id'])

        # Adding model 'Attachment'
        db.create_table('articles_attachment', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=250, db_index=True)),
            ('slug', self.gf('autoslug.fields.AutoSlugField')(unique=True, max_length=50, populate_from=None, unique_with=(), db_index=True)),
            ('article', self.gf('django.db.models.fields.related.ForeignKey')(related_name=u'attachments', to=orm['articles.Article'])),
            ('description', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=250, blank=True)),
            ('file', self.gf('django.db.models.fields.files.FileField')(max_length=250, db_index=True)),
            ('downloads', self.gf('django.db.models.fields.IntegerField')(default=0, blank=True)),
        ))
        db.send_create_signal('articles', ['Attachment'])

0 View Complete Implementation : generic.py
Copyright Apache License 2.0
Author : edisonlz
    def mock_model(self, model_name, db_table, db_tablespace='',
                   pk_field_name='id', pk_field_type=models.AutoField,
                   pk_field_args=[], pk_field_kwargs={}):
        """
        Generates a MockModel clast that provides enough information
        to be used by a foreign key/many-to-many relationship.

        Migrations should prefer to use these rather than actual models
        as models could get deleted over time, but these can remain in
        migration files forever.

        Depreciated.
        """
        clast MockOptions(object):
            def __init__(self):
                self.db_table = db_table
                self.db_tablespace = db_tablespace or settings.DEFAULT_TABLESPACE
                self.object_name = model_name
                self.module_name = model_name.lower()

                if pk_field_type == models.AutoField:
                    pk_field_kwargs['primary_key'] = True

                self.pk = pk_field_type(*pk_field_args, **pk_field_kwargs)
                self.pk.set_attributes_from_name(pk_field_name)
                self.abstract = False

            def get_field_by_name(self, field_name):
                # we only care about the pk field
                return (self.pk, self.model, True, False)

            def get_field(self, name):
                # we only care about the pk field
                return self.pk

        clast MockModel(object):
            _meta = None

        # We need to return an actual clast object here, not an instance
        MockModel._meta = MockOptions()
        MockModel._meta.model = MockModel
        return MockModel

0 View Complete Implementation : oracle.py
Copyright Apache License 2.0
Author : edisonlz
    @generic.invalidate_table_constraints
    def create_table(self, table_name, fields): 
        qn = self.quote_name(table_name)
        columns = []
        autoinc_sql = ''

        for field_name, field in fields:
            col = self.column_sql(table_name, field_name, field)
            if not col:
                continue
            col = self.adj_column_sql(col)

            columns.append(col)
            if isinstance(field, models.AutoField):
                autoinc_sql = connection.ops.autoinc_sql(table_name, field_name)

        sql = 'CREATE TABLE %s (%s);' % (qn, ', '.join([col for col in columns]))
        self.execute(sql)
        if autoinc_sql:
            self.execute(autoinc_sql[0])
            self.execute(autoinc_sql[1])

0 View Complete Implementation : db.py
Copyright Apache License 2.0
Author : edisonlz
    def test_unique(self):
        """
        Tests creating/deleting unique constraints.
        """
        
        # SQLite backend doesn't support this yet.
        if db.backend_name == "sqlite3":
            return
        
        db.create_table("test_unique2", [
            ('id', models.AutoField(primary_key=True)),
        ])
        db.create_table("test_unique", [
            ('spam', models.BooleanField(default=False)),
            ('eggs', models.IntegerField()),
            ('ham', models.ForeignKey(db.mock_model('Unique2', 'test_unique2'))),
        ])
        db.execute_deferred_sql()
        # Add a constraint
        db.create_unique("test_unique", ["spam"])
        db.execute_deferred_sql()
        # Shouldn't do anything during dry-run
        db.dry_run = True
        db.delete_unique("test_unique", ["spam"])
        db.dry_run = False
        db.delete_unique("test_unique", ["spam"])
        db.create_unique("test_unique", ["spam"])
        # Special preparations for Sql Server
        if db.backend_name == "pyodbc":
            db.execute("SET IDENsatY_INSERT test_unique2 ON;")
        db.execute("INSERT INTO test_unique2 (id) VALUES (1)")
        db.execute("INSERT INTO test_unique2 (id) VALUES (2)")
        db.commit_transaction()
        db.start_transaction()

        
        # Test it works
        TRUE = (True,)
        FALSE = (False,)
        db.execute("INSERT INTO test_unique (spam, eggs, ham_id) VALUES (%s, 0, 1)", TRUE)
        db.execute("INSERT INTO test_unique (spam, eggs, ham_id) VALUES (%s, 1, 2)", FALSE)
        try:
            db.execute("INSERT INTO test_unique (spam, eggs, ham_id) VALUES (%s, 2, 1)", FALSE)
        except:
            db.rollback_transaction()
        else:
            self.fail("Could insert non-unique item.")
        
        # Drop that, add one only on eggs
        db.delete_unique("test_unique", ["spam"])
        db.execute("DELETE FROM test_unique")
        db.create_unique("test_unique", ["eggs"])
        db.start_transaction()
        
        # Test similarly
        db.execute("INSERT INTO test_unique (spam, eggs, ham_id) VALUES (%s, 0, 1)", TRUE)
        db.execute("INSERT INTO test_unique (spam, eggs, ham_id) VALUES (%s, 1, 2)", FALSE)
        try:
            db.execute("INSERT INTO test_unique (spam, eggs, ham_id) VALUES (%s, 1, 1)", TRUE)
        except:
            db.rollback_transaction()
        else:
            self.fail("Could insert non-unique item.")
        
        # Drop those, test combined constraints
        db.delete_unique("test_unique", ["eggs"])
        db.execute("DELETE FROM test_unique")
        db.create_unique("test_unique", ["spam", "eggs", "ham_id"])
        db.start_transaction()
        # Test similarly
        db.execute("INSERT INTO test_unique (spam, eggs, ham_id) VALUES (%s, 0, 1)", TRUE)
        db.execute("INSERT INTO test_unique (spam, eggs, ham_id) VALUES (%s, 1, 1)", FALSE)
        try:
            db.execute("INSERT INTO test_unique (spam, eggs, ham_id) VALUES (%s, 0, 1)", TRUE)
        except:
            db.rollback_transaction()
        else:
            self.fail("Could insert non-unique pair.")
        db.delete_unique("test_unique", ["spam", "eggs", "ham_id"])
        db.start_transaction()

0 View Complete Implementation : firebird.py
Copyright Apache License 2.0
Author : edisonlz
    @generic.invalidate_table_constraints
    def create_table(self, table_name, fields):
        qn = self.quote_name(table_name)
        columns = []
        autoinc_sql = ''

        for field_name, field in fields:
            col = self.column_sql(table_name, field_name, field)
            if not col:
                continue
            #col = self.adj_column_sql(col)

            columns.append(col)
            if isinstance(field, models.AutoField):
                field_name = field.db_column or field.column
                autoinc_sql = connection.ops.autoinc_sql(table_name, field_name)

        sql = 'CREATE TABLE %s (%s);' % (qn, ', '.join([col for col in columns]))
        self.execute(sql)
        if autoinc_sql:
            self.execute(autoinc_sql[0])
            self.execute(autoinc_sql[1])

0 View Complete Implementation : 0001_first_migration.py
Copyright BSD 2-Clause "Simplified" License
Author : evrenesat
    def forwards(self, orm):
        # Adding model 'PayPalIPN'
        db.create_table('paypal_ipn', (
            ('id', models.AutoField(primary_key=True)),
            ('business', models.CharField(max_length=127, blank=True)),
            ('charset', models.CharField(max_length=32, blank=True)),
            ('custom', models.CharField(max_length=255, blank=True)),
            ('notify_version', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('parent_txn_id', models.CharField("Parent Transaction ID", max_length=19, blank=True)),
            ('receiver_email', models.EmailField(max_length=127, blank=True)),
            ('receiver_id', models.CharField(max_length=127, blank=True)),
            ('residence_country', models.CharField(max_length=2, blank=True)),
            ('test_ipn', models.BooleanField(default=False, blank=True)),
            ('txn_id', models.CharField("Transaction ID", max_length=19, blank=True)),
            ('txn_type', models.CharField("Transaction Type", max_length=128, blank=True)),
            ('verify_sign', models.CharField(max_length=255, blank=True)),
            ('address_country', models.CharField(max_length=64, blank=True)),
            ('address_city', models.CharField(max_length=40, blank=True)),
            ('address_country_code', models.CharField(max_length=64, blank=True)),
            ('address_name', models.CharField(max_length=128, blank=True)),
            ('address_state', models.CharField(max_length=40, blank=True)),
            ('address_status', models.CharField(max_length=11, blank=True)),
            ('address_street', models.CharField(max_length=200, blank=True)),
            ('address_zip', models.CharField(max_length=20, blank=True)),
            ('contact_phone', models.CharField(max_length=20, blank=True)),
            ('first_name', models.CharField(max_length=64, blank=True)),
            ('last_name', models.CharField(max_length=64, blank=True)),
            ('payer_business_name', models.CharField(max_length=127, blank=True)),
            ('payer_email', models.CharField(max_length=127, blank=True)),
            ('payer_id', models.CharField(max_length=13, blank=True)),
            ('auth_amount', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('auth_exp', models.CharField(max_length=28, blank=True)),
            ('auth_id', models.CharField(max_length=19, blank=True)),
            ('auth_status', models.CharField(max_length=9, blank=True)),
            ('exchange_rate', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=16, blank=True)),
            ('invoice', models.CharField(max_length=127, blank=True)),
            ('item_name', models.CharField(max_length=127, blank=True)),
            ('item_number', models.CharField(max_length=127, blank=True)),
            ('mc_currency', models.CharField(default='USD', max_length=32, blank=True)),
            ('mc_fee', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('mc_gross', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('mc_handling', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('mc_shipping', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('memo', models.CharField(max_length=255, blank=True)),
            ('num_cart_items', models.IntegerField(default=0, null=True, blank=True)),
            ('option_name1', models.CharField(max_length=64, blank=True)),
            ('option_name2', models.CharField(max_length=64, blank=True)),
            ('payer_status', models.CharField(max_length=10, blank=True)),
            ('payment_date', models.DateTimeField(null=True, blank=True)),
            ('payment_gross', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('payment_status', models.CharField(max_length=9, blank=True)),
            ('payment_type', models.CharField(max_length=7, blank=True)),
            ('pending_reason', models.CharField(max_length=14, blank=True)),
            ('protection_eligibility', models.CharField(max_length=32, blank=True)),
            ('quansaty', models.IntegerField(default=1, null=True, blank=True)),
            ('reason_code', models.CharField(max_length=15, blank=True)),
            ('remaining_settle', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('settle_amount', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('settle_currency', models.CharField(max_length=32, blank=True)),
            ('shipping', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('shipping_method', models.CharField(max_length=255, blank=True)),
            ('tax', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('transaction_ensaty', models.CharField(max_length=7, blank=True)),
            ('auction_buyer_id', models.CharField(max_length=64, blank=True)),
            ('auction_closing_date', models.DateTimeField(null=True, blank=True)),
            ('auction_multi_item', models.IntegerField(default=0, null=True, blank=True)),
            ('for_auction', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('amount', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('amount_per_cycle', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('initial_payment_amount', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('next_payment_date', models.DateTimeField(null=True, blank=True)),
            ('outstanding_balance', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('payment_cycle', models.CharField(max_length=32, blank=True)),
            ('period_type', models.CharField(max_length=32, blank=True)),
            ('product_name', models.CharField(max_length=128, blank=True)),
            ('product_type', models.CharField(max_length=128, blank=True)),
            ('profile_status', models.CharField(max_length=32, blank=True)),
            ('recurring_payment_id', models.CharField(max_length=128, blank=True)),
            ('rp_invoice_id', models.CharField(max_length=127, blank=True)),
            ('time_created', models.DateTimeField(null=True, blank=True)),
            ('amount1', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('amount2', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('amount3', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('mc_amount1', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('mc_amount2', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('mc_amount3', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('pastword', models.CharField(max_length=24, blank=True)),
            ('period1', models.CharField(max_length=32, blank=True)),
            ('period2', models.CharField(max_length=32, blank=True)),
            ('period3', models.CharField(max_length=32, blank=True)),
            ('reattempt', models.CharField(max_length=1, blank=True)),
            ('recur_times', models.IntegerField(default=0, null=True, blank=True)),
            ('recurring', models.CharField(max_length=1, blank=True)),
            ('retry_at', models.DateTimeField(null=True, blank=True)),
            ('subscr_date', models.DateTimeField(null=True, blank=True)),
            ('subscr_effective', models.DateTimeField(null=True, blank=True)),
            ('subscr_id', models.CharField(max_length=19, blank=True)),
            ('username', models.CharField(max_length=64, blank=True)),
            ('case_creation_date', models.DateTimeField(null=True, blank=True)),
            ('case_id', models.CharField(max_length=14, blank=True)),
            ('case_type', models.CharField(max_length=24, blank=True)),
            ('receipt_id', models.CharField(max_length=64, blank=True)),
            ('currency_code', models.CharField(default='USD', max_length=32, blank=True)),
            ('handling_amount', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('transaction_subject', models.CharField(max_length=255, blank=True)),
            ('ipaddress', models.IPAddressField(blank=True)),
            ('flag', models.BooleanField(default=False, blank=True)),
            ('flag_code', models.CharField(max_length=16, blank=True)),
            ('flag_info', models.TextField(blank=True)),
            ('query', models.TextField(blank=True)),
            ('response', models.TextField(blank=True)),
            ('created_at', models.DateTimeField(auto_now_add=True)),
            ('updated_at', models.DateTimeField(auto_now=True)),
            ('from_view', models.CharField(max_length=6, null=True, blank=True)),
        ))
        db.send_create_signal('ipn', ['PayPalIPN'])

0 View Complete Implementation : 0001_first_migration.py
Copyright BSD 2-Clause "Simplified" License
Author : evrenesat
    def forwards(self, orm):
        
        # Adding model 'PayPalPDT'
        db.create_table('paypal_pdt', (
            ('id', models.AutoField(primary_key=True)),
            ('business', models.CharField(max_length=127, blank=True)),
            ('charset', models.CharField(max_length=32, blank=True)),
            ('custom', models.CharField(max_length=255, blank=True)),
            ('notify_version', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('parent_txn_id', models.CharField("Parent Transaction ID", max_length=19, blank=True)),
            ('receiver_email', models.EmailField(max_length=127, blank=True)),
            ('receiver_id', models.CharField(max_length=127, blank=True)),
            ('residence_country', models.CharField(max_length=2, blank=True)),
            ('test_ipn', models.BooleanField(default=False, blank=True)),
            ('txn_id', models.CharField("Transaction ID", max_length=19, blank=True)),
            ('txn_type', models.CharField("Transaction Type", max_length=128, blank=True)),
            ('verify_sign', models.CharField(max_length=255, blank=True)),
            ('address_country', models.CharField(max_length=64, blank=True)),
            ('address_city', models.CharField(max_length=40, blank=True)),
            ('address_country_code', models.CharField(max_length=64, blank=True)),
            ('address_name', models.CharField(max_length=128, blank=True)),
            ('address_state', models.CharField(max_length=40, blank=True)),
            ('address_status', models.CharField(max_length=11, blank=True)),
            ('address_street', models.CharField(max_length=200, blank=True)),
            ('address_zip', models.CharField(max_length=20, blank=True)),
            ('contact_phone', models.CharField(max_length=20, blank=True)),
            ('first_name', models.CharField(max_length=64, blank=True)),
            ('last_name', models.CharField(max_length=64, blank=True)),
            ('payer_business_name', models.CharField(max_length=127, blank=True)),
            ('payer_email', models.CharField(max_length=127, blank=True)),
            ('payer_id', models.CharField(max_length=13, blank=True)),
            ('auth_amount', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('auth_exp', models.CharField(max_length=28, blank=True)),
            ('auth_id', models.CharField(max_length=19, blank=True)),
            ('auth_status', models.CharField(max_length=9, blank=True)),
            ('exchange_rate', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=16, blank=True)),
            ('invoice', models.CharField(max_length=127, blank=True)),
            ('item_name', models.CharField(max_length=127, blank=True)),
            ('item_number', models.CharField(max_length=127, blank=True)),
            ('mc_currency', models.CharField(default='USD', max_length=32, blank=True)),
            ('mc_fee', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('mc_gross', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('mc_handling', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('mc_shipping', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('memo', models.CharField(max_length=255, blank=True)),
            ('num_cart_items', models.IntegerField(default=0, null=True, blank=True)),
            ('option_name1', models.CharField(max_length=64, blank=True)),
            ('option_name2', models.CharField(max_length=64, blank=True)),
            ('payer_status', models.CharField(max_length=10, blank=True)),
            ('payment_date', models.DateTimeField(null=True, blank=True)),
            ('payment_gross', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('payment_status', models.CharField(max_length=9, blank=True)),
            ('payment_type', models.CharField(max_length=7, blank=True)),
            ('pending_reason', models.CharField(max_length=14, blank=True)),
            ('protection_eligibility', models.CharField(max_length=32, blank=True)),
            ('quansaty', models.IntegerField(default=1, null=True, blank=True)),
            ('reason_code', models.CharField(max_length=15, blank=True)),
            ('remaining_settle', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('settle_amount', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('settle_currency', models.CharField(max_length=32, blank=True)),
            ('shipping', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('shipping_method', models.CharField(max_length=255, blank=True)),
            ('tax', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('transaction_ensaty', models.CharField(max_length=7, blank=True)),
            ('auction_buyer_id', models.CharField(max_length=64, blank=True)),
            ('auction_closing_date', models.DateTimeField(null=True, blank=True)),
            ('auction_multi_item', models.IntegerField(default=0, null=True, blank=True)),
            ('for_auction', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('amount', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('amount_per_cycle', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('initial_payment_amount', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('next_payment_date', models.DateTimeField(null=True, blank=True)),
            ('outstanding_balance', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('payment_cycle', models.CharField(max_length=32, blank=True)),
            ('period_type', models.CharField(max_length=32, blank=True)),
            ('product_name', models.CharField(max_length=128, blank=True)),
            ('product_type', models.CharField(max_length=128, blank=True)),
            ('profile_status', models.CharField(max_length=32, blank=True)),
            ('recurring_payment_id', models.CharField(max_length=128, blank=True)),
            ('rp_invoice_id', models.CharField(max_length=127, blank=True)),
            ('time_created', models.DateTimeField(null=True, blank=True)),
            ('amount1', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('amount2', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('amount3', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('mc_amount1', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('mc_amount2', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('mc_amount3', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('pastword', models.CharField(max_length=24, blank=True)),
            ('period1', models.CharField(max_length=32, blank=True)),
            ('period2', models.CharField(max_length=32, blank=True)),
            ('period3', models.CharField(max_length=32, blank=True)),
            ('reattempt', models.CharField(max_length=1, blank=True)),
            ('recur_times', models.IntegerField(default=0, null=True, blank=True)),
            ('recurring', models.CharField(max_length=1, blank=True)),
            ('retry_at', models.DateTimeField(null=True, blank=True)),
            ('subscr_date', models.DateTimeField(null=True, blank=True)),
            ('subscr_effective', models.DateTimeField(null=True, blank=True)),
            ('subscr_id', models.CharField(max_length=19, blank=True)),
            ('username', models.CharField(max_length=64, blank=True)),
            ('case_creation_date', models.DateTimeField(null=True, blank=True)),
            ('case_id', models.CharField(max_length=14, blank=True)),
            ('case_type', models.CharField(max_length=24, blank=True)),
            ('receipt_id', models.CharField(max_length=64, blank=True)),
            ('currency_code', models.CharField(default='USD', max_length=32, blank=True)),
            ('handling_amount', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('transaction_subject', models.CharField(max_length=255, blank=True)),
            ('ipaddress', models.IPAddressField(blank=True)),
            ('flag', models.BooleanField(default=False, blank=True)),
            ('flag_code', models.CharField(max_length=16, blank=True)),
            ('flag_info', models.TextField(blank=True)),
            ('query', models.TextField(blank=True)),
            ('response', models.TextField(blank=True)),
            ('created_at', models.DateTimeField(auto_now_add=True)),
            ('updated_at', models.DateTimeField(auto_now=True)),
            ('from_view', models.CharField(max_length=6, null=True, blank=True)),
            ('amt', models.DecimalField(default=0, null=True, max_digits=64, decimal_places=2, blank=True)),
            ('cm', models.CharField(max_length=255, blank=True)),
            ('sig', models.CharField(max_length=255, blank=True)),
            ('tx', models.CharField(max_length=255, blank=True)),
            ('st', models.CharField(max_length=32, blank=True)),
        ))
        db.send_create_signal('pdt', ['PayPalPDT'])

0 View Complete Implementation : 0001_initial.py
Copyright BSD 2-Clause "Simplified" License
Author : evrenesat
    def forwards(self, orm):
        
        # Adding model 'Transaction'
        db.create_table('places_transaction', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])),
            ('amount', self.gf('django.db.models.fields.DecimalField')(max_digits=8, decimal_places=2)),
            ('type', self.gf('django.db.models.fields.SmallIntegerField')()),
            ('reciver_type', self.gf('django.db.models.fields.SmallIntegerField')()),
            ('sender_type', self.gf('django.db.models.fields.SmallIntegerField')()),
            ('timestamp', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
            ('content_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['contenttypes.ContentType'])),
            ('object_id', self.gf('django.db.models.fields.PositiveIntegerField')()),
            ('details', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
        ))
        db.send_create_signal('places', ['Transaction'])

        # Adding model 'TagCategory'
        db.create_table('places_tagcategory', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=30)),
            ('active', self.gf('django.db.models.fields.BooleanField')(default=True)),
            ('timestamp', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
        ))
        db.send_create_signal('places', ['TagCategory'])

        # Adding model 'Tag'
        db.create_table('places_tag', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('category', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['places.TagCategory'])),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=30)),
            ('active', self.gf('django.db.models.fields.BooleanField')(default=True)),
            ('timestamp', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
        ))
        db.send_create_signal('places', ['Tag'])

        # Adding model 'Place'
        db.create_table('places_place', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('owner', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])),
            ('satle', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('country', self.gf('django.db.models.fields.CharField')(max_length=2)),
            ('street', self.gf('django.db.models.fields.CharField')(max_length=60)),
            ('postcode', self.gf('django.db.models.fields.CharField')(max_length=15)),
            ('city', self.gf('django.db.models.fields.CharField')(max_length=40)),
            ('district', self.gf('django.db.models.fields.CharField')(max_length=40)),
            ('state', self.gf('django.db.models.fields.CharField')(max_length=40)),
            ('emergency_phone', self.gf('django.db.models.fields.CharField')(max_length=20)),
            ('phone', self.gf('django.db.models.fields.CharField')(max_length=20)),
            ('type', self.gf('django.db.models.fields.SmallIntegerField')()),
            ('space', self.gf('django.db.models.fields.SmallIntegerField')()),
            ('bedroom', self.gf('django.db.models.fields.SmallIntegerField')()),
            ('bed_type', self.gf('django.db.models.fields.SmallIntegerField')()),
            ('bathrooms', self.gf('django.db.models.fields.SmallIntegerField')()),
            ('size', self.gf('django.db.models.fields.IntegerField')()),
            ('pets', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('cancellation', self.gf('django.db.models.fields.SmallIntegerField')()),
            ('min_stay', self.gf('django.db.models.fields.SmallIntegerField')(default=1)),
            ('max_stay', self.gf('django.db.models.fields.SmallIntegerField')(default=0)),
            ('manual', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
            ('rules', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
            ('price', self.gf('django.db.models.fields.DecimalField')(max_digits=6, decimal_places=2)),
            ('weekly_discount', self.gf('django.db.models.fields.SmallIntegerField')(null=True, blank=True)),
            ('monthly_discount', self.gf('django.db.models.fields.SmallIntegerField')(null=True, blank=True)),
            ('capacity', self.gf('django.db.models.fields.SmallIntegerField')()),
            ('extra_limit', self.gf('django.db.models.fields.SmallIntegerField')(null=True, blank=True)),
            ('extra_price', self.gf('django.db.models.fields.DecimalField')(null=True, max_digits=6, decimal_places=2, blank=True)),
            ('cleaning_fee', self.gf('django.db.models.fields.DecimalField')(null=True, max_digits=8, decimal_places=2, blank=True)),
            ('street_view', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('timestamp', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
        ))
        db.send_create_signal('places', ['Place'])

        # Adding M2M table for field tags on 'Place'
        db.create_table('places_place_tags', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('place', models.ForeignKey(orm['places.place'], null=False)),
            ('tag', models.ForeignKey(orm['places.tag'], null=False))
        ))
        db.create_unique('places_place_tags', ['place_id', 'tag_id'])

        # Adding model 'Profile'
        db.create_table('places_profile', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('lastlogin', self.gf('django.db.models.fields.DateTimeField')()),
            ('usr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['auth.User'], unique=True)),
            ('city', self.gf('django.db.models.fields.CharField')(max_length=30)),
            ('phone', self.gf('django.db.models.fields.CharField')(max_length=20, null=True, blank=True)),
            ('cell', self.gf('django.db.models.fields.CharField')(max_length=20, null=True, blank=True)),
            ('occupation', self.gf('django.db.models.fields.CharField')(max_length=30, null=True, blank=True)),
            ('twitter', self.gf('django.db.models.fields.CharField')(max_length=60, null=True, blank=True)),
            ('facebook', self.gf('django.db.models.fields.CharField')(max_length=60, null=True, blank=True)),
            ('brithdate', self.gf('django.db.models.fields.DateField')(null=True, blank=True)),
            ('lang', self.gf('django.db.models.fields.CharField')(max_length=5)),
            ('timestamp', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
        ))
        db.send_create_signal('places', ['Profile'])

        # Adding M2M table for field favorites on 'Profile'
        db.create_table('places_profile_favorites', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('profile', models.ForeignKey(orm['places.profile'], null=False)),
            ('place', models.ForeignKey(orm['places.place'], null=False))
        ))
        db.create_unique('places_profile_favorites', ['profile_id', 'place_id'])

        # Adding model 'Friendship'
        db.create_table('places_friendship', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('profile', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['places.Profile'])),
            ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])),
            ('confirmed', self.gf('django.db.models.fields.BooleanField')(default=False)),
        ))
        db.send_create_signal('places', ['Friendship'])

        # Adding model 'Photo'
        db.create_table('places_photo', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('place', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['places.Place'])),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=60, null=True, blank=True)),
            ('image', self.gf('django.db.models.fields.files.ImageField')(max_length=100)),
            ('timestamp', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
        ))
        db.send_create_signal('places', ['Photo'])

        # Adding model 'ReservedDates'
        db.create_table('places_reserveddates', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('start', self.gf('django.db.models.fields.DateField')()),
            ('end', self.gf('django.db.models.fields.DateField')()),
            ('timestamp', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
        ))
        db.send_create_signal('places', ['ReservedDates'])

        # Adding model 'Booking'
        db.create_table('places_booking', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('host', self.gf('django.db.models.fields.related.ForeignKey')(related_name='host', to=orm['auth.User'])),
            ('guest', self.gf('django.db.models.fields.related.ForeignKey')(related_name='guest', to=orm['auth.User'])),
            ('place', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['places.Place'])),
            ('reservation', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['places.ReservedDates'])),
            ('start', self.gf('django.db.models.fields.DateField')()),
            ('end', self.gf('django.db.models.fields.DateField')()),
            ('summary', self.gf('django.db.models.fields.CharField')(max_length=100, null=True, blank=True)),
            ('valid', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('status', self.gf('django.db.models.fields.SmallIntegerField')(default=1)),
            ('payment_type', self.gf('django.db.models.fields.SmallIntegerField')(null=True, blank=True)),
            ('guest_payment', self.gf('django.db.models.fields.DecimalField')(max_digits=8, decimal_places=2)),
            ('host_earning', self.gf('django.db.models.fields.DecimalField')(max_digits=8, decimal_places=2)),
            ('timestamp', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
        ))
        db.send_create_signal('places', ['Booking'])

        # Adding model 'SessionalPrice'
        db.create_table('places_sessionalprice', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('price', self.gf('django.db.models.fields.DecimalField')(max_digits=8, decimal_places=2)),
            ('weekend_price', self.gf('django.db.models.fields.DecimalField')(null=True, max_digits=8, decimal_places=2, blank=True)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=30, null=True, blank=True)),
            ('start', self.gf('django.db.models.fields.DateField')()),
            ('end', self.gf('django.db.models.fields.DateField')()),
            ('timestamp', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
        ))
        db.send_create_signal('places', ['SessionalPrice'])

        # Adding model 'Description'
        db.create_table('places_description', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('place', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['places.Place'])),
            ('lang', self.gf('django.db.models.fields.CharField')(max_length=5)),
            ('text', self.gf('django.db.models.fields.TextField')()),
            ('auto', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('timestamp', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
        ))
        db.send_create_signal('places', ['Description'])

        # Adding model 'Message'
        db.create_table('places_message', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('sender', self.gf('django.db.models.fields.related.ForeignKey')(related_name='sender', to=orm['auth.User'])),
            ('receiver', self.gf('django.db.models.fields.related.ForeignKey')(related_name='receiver', to=orm['auth.User'])),
            ('text', self.gf('django.db.models.fields.TextField')()),
            ('read', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('status', self.gf('django.db.models.fields.SmallIntegerField')(default=1)),
            ('timestamp', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
        ))
        db.send_create_signal('places', ['Message'])

        # Adding model 'UserReview'
        db.create_table('places_userreview', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('writer', self.gf('django.db.models.fields.related.ForeignKey')(related_name='writer', to=orm['auth.User'])),
            ('person', self.gf('django.db.models.fields.related.ForeignKey')(related_name='person', to=orm['auth.User'])),
            ('text', self.gf('django.db.models.fields.TextField')()),
            ('active', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('status', self.gf('django.db.models.fields.SmallIntegerField')(default=1)),
            ('timestamp', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
        ))
        db.send_create_signal('places', ['UserReview'])

        # Adding model 'PlaceReview'
        db.create_table('places_placereview', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('writer', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])),
            ('place', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['places.Place'])),
            ('text', self.gf('django.db.models.fields.TextField')()),
            ('rating', self.gf('django.db.models.fields.SmallIntegerField')(default=0)),
            ('active', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('status', self.gf('django.db.models.fields.SmallIntegerField')(default=1)),
            ('timestamp', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
        ))
        db.send_create_signal('places', ['PlaceReview'])

0 View Complete Implementation : 0048_auto__del_geoplanet__add_geolocation__del_field_place_woeid.py
Copyright BSD 2-Clause "Simplified" License
Author : evrenesat
    def forwards(self, orm):
        
        # Deleting model 'GeoPlanet'
        db.delete_table('places_geoplanet')

        # Adding model 'GeoLocation'
        db.create_table('places_geolocation', (
            ('id', self.gf('django.db.models.fields.IntegerField')(primary_key=True)),
            ('iso', self.gf('django.db.models.fields.CharField')(max_length=2, db_index=True)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=100, db_index=True)),
            ('type', self.gf('django.db.models.fields.SmallIntegerField')()),
            ('parent', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['places.GeoLocation'])),
        ))
        db.send_create_signal('places', ['GeoLocation'])

        # Deleting field 'Place.woeid'
        db.delete_column('places_place', 'woeid')

        # Adding M2M table for field placement on 'Place'
        db.create_table('places_place_placement', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('place', models.ForeignKey(orm['places.place'], null=False)),
            ('geolocation', models.ForeignKey(orm['places.geolocation'], null=False))
        ))
        db.create_unique('places_place_placement', ['place_id', 'geolocation_id'])

0 View Complete Implementation : converter.py
Copyright MIT License
Author : graphql-python
@convert_django_field.register(models.AutoField)
def convert_field_to_id(field, registry=None):
    return ID(description=field.help_text, required=not field.null)

0 View Complete Implementation : 0001_initial.py
Copyright MIT License
Author : Arx-Game
    def forwards(self, orm):
        
        # Adding model 'Queue'
        db.create_table('helpdesk_queue', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('satle', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('slug', self.gf('django.db.models.fields.SlugField')(max_length=50, db_index=True)),
            ('email_address', self.gf('django.db.models.fields.EmailField')(max_length=75, null=True, blank=True)),
            ('locale', self.gf('django.db.models.fields.CharField')(max_length=10, null=True, blank=True)),
            ('allow_public_submission', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('allow_email_submission', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('escalate_days', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True)),
            ('new_ticket_cc', self.gf('django.db.models.fields.CharField')(max_length=200, null=True, blank=True)),
            ('updated_ticket_cc', self.gf('django.db.models.fields.CharField')(max_length=200, null=True, blank=True)),
            ('email_box_type', self.gf('django.db.models.fields.CharField')(max_length=5, null=True, blank=True)),
            ('email_box_host', self.gf('django.db.models.fields.CharField')(max_length=200, null=True, blank=True)),
            ('email_box_port', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True)),
            ('email_box_ssl', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('email_box_user', self.gf('django.db.models.fields.CharField')(max_length=200, null=True, blank=True)),
            ('email_box_past', self.gf('django.db.models.fields.CharField')(max_length=200, null=True, blank=True)),
            ('email_box_imap_folder', self.gf('django.db.models.fields.CharField')(max_length=100, null=True, blank=True)),
            ('email_box_interval', self.gf('django.db.models.fields.IntegerField')(default='5', null=True, blank=True)),
            ('email_box_last_check', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
        ))
        db.send_create_signal('helpdesk', ['Queue'])

        # Adding model 'Ticket'
        db.create_table('helpdesk_ticket', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('satle', self.gf('django.db.models.fields.CharField')(max_length=200)),
            ('queue', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['helpdesk.Queue'])),
            ('created', self.gf('django.db.models.fields.DateTimeField')(blank=True)),
            ('modified', self.gf('django.db.models.fields.DateTimeField')(blank=True)),
            ('submitter_email', self.gf('django.db.models.fields.EmailField')(max_length=75, null=True, blank=True)),
            ('astigned_to', self.gf('django.db.models.fields.related.ForeignKey')(related_name='astigned_to', blank=True, null=True, to=orm['auth.User'])),
            ('status', self.gf('django.db.models.fields.IntegerField')(default=1)),
            ('on_hold', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('description', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
            ('resolution', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
            ('priority', self.gf('django.db.models.fields.IntegerField')(default=3, blank=3)),
            ('last_escalation', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
        ))
        db.send_create_signal('helpdesk', ['Ticket'])

        # Adding model 'FollowUp'
        db.create_table('helpdesk_followup', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('ticket', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['helpdesk.Ticket'])),
            ('date', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime(2011, 4, 27, 15, 17, 4, 272904))),
            ('satle', self.gf('django.db.models.fields.CharField')(max_length=200, null=True, blank=True)),
            ('comment', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
            ('public', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True, blank=True)),
            ('new_status', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True)),
        ))
        db.send_create_signal('helpdesk', ['FollowUp'])

        # Adding model 'TicketChange'
        db.create_table('helpdesk_ticketchange', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('followup', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['helpdesk.FollowUp'])),
            ('field', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('old_value', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
            ('new_value', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
        ))
        db.send_create_signal('helpdesk', ['TicketChange'])

        # Adding model 'Attachment'
        db.create_table('helpdesk_attachment', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('followup', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['helpdesk.FollowUp'])),
            ('file', self.gf('django.db.models.fields.files.FileField')(max_length=100)),
            ('filename', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('mime_type', self.gf('django.db.models.fields.CharField')(max_length=30)),
            ('size', self.gf('django.db.models.fields.IntegerField')()),
        ))
        db.send_create_signal('helpdesk', ['Attachment'])

        # Adding model 'PreSetReply'
        db.create_table('helpdesk_presetreply', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('body', self.gf('django.db.models.fields.TextField')()),
        ))
        db.send_create_signal('helpdesk', ['PreSetReply'])

        # Adding M2M table for field queues on 'PreSetReply'
        db.create_table('helpdesk_presetreply_queues', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('presetreply', models.ForeignKey(orm['helpdesk.presetreply'], null=False)),
            ('queue', models.ForeignKey(orm['helpdesk.queue'], null=False))
        ))
        db.create_unique('helpdesk_presetreply_queues', ['presetreply_id', 'queue_id'])

        # Adding model 'EscalationExclusion'
        db.create_table('helpdesk_escalationexclusion', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('date', self.gf('django.db.models.fields.DateField')()),
        ))
        db.send_create_signal('helpdesk', ['EscalationExclusion'])

        # Adding M2M table for field queues on 'EscalationExclusion'
        db.create_table('helpdesk_escalationexclusion_queues', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('escalationexclusion', models.ForeignKey(orm['helpdesk.escalationexclusion'], null=False)),
            ('queue', models.ForeignKey(orm['helpdesk.queue'], null=False))
        ))
        db.create_unique('helpdesk_escalationexclusion_queues', ['escalationexclusion_id', 'queue_id'])

        # Adding model 'EmailTemplate'
        db.create_table('helpdesk_emailtemplate', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('template_name', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('subject', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('heading', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('plain_text', self.gf('django.db.models.fields.TextField')()),
            ('html', self.gf('django.db.models.fields.TextField')()),
            ('locale', self.gf('django.db.models.fields.CharField')(max_length=10, null=True, blank=True)),
        ))
        db.send_create_signal('helpdesk', ['EmailTemplate'])

        # Adding model 'KBCategory'
        db.create_table('helpdesk_kbcategory', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('satle', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('slug', self.gf('django.db.models.fields.SlugField')(max_length=50, db_index=True)),
            ('description', self.gf('django.db.models.fields.TextField')()),
        ))
        db.send_create_signal('helpdesk', ['KBCategory'])

        # Adding model 'KBItem'
        db.create_table('helpdesk_kbitem', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('category', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['helpdesk.KBCategory'])),
            ('satle', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('question', self.gf('django.db.models.fields.TextField')()),
            ('answer', self.gf('django.db.models.fields.TextField')()),
            ('votes', self.gf('django.db.models.fields.IntegerField')(default=0)),
            ('recommendations', self.gf('django.db.models.fields.IntegerField')(default=0)),
            ('last_updated', self.gf('django.db.models.fields.DateTimeField')(blank=True)),
        ))
        db.send_create_signal('helpdesk', ['KBItem'])

        # Adding model 'SavedSearch'
        db.create_table('helpdesk_savedsearch', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])),
            ('satle', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('shared', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('query', self.gf('django.db.models.fields.TextField')()),
        ))
        db.send_create_signal('helpdesk', ['SavedSearch'])

        # Adding model 'UserSettings'
        db.create_table('helpdesk_usersettings', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('user', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['auth.User'], unique=True)),
            ('settings_pickled', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
        ))
        db.send_create_signal('helpdesk', ['UserSettings'])

        # Adding model 'IgnoreEmail'
        db.create_table('helpdesk_ignoreemail', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('date', self.gf('django.db.models.fields.DateField')(blank=True)),
            ('email_address', self.gf('django.db.models.fields.CharField')(max_length=150)),
            ('keep_in_mailbox', self.gf('django.db.models.fields.BooleanField')(default=False)),
        ))
        db.send_create_signal('helpdesk', ['IgnoreEmail'])

        # Adding M2M table for field queues on 'IgnoreEmail'
        db.create_table('helpdesk_ignoreemail_queues', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('ignoreemail', models.ForeignKey(orm['helpdesk.ignoreemail'], null=False)),
            ('queue', models.ForeignKey(orm['helpdesk.queue'], null=False))
        ))
        db.create_unique('helpdesk_ignoreemail_queues', ['ignoreemail_id', 'queue_id'])

        # Adding model 'TicketCC'
        db.create_table('helpdesk_ticketcc', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('ticket', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['helpdesk.Ticket'])),
            ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True, blank=True)),
            ('email', self.gf('django.db.models.fields.EmailField')(max_length=75, null=True, blank=True)),
            ('can_view', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('can_update', self.gf('django.db.models.fields.BooleanField')(default=False)),
        ))
        db.send_create_signal('helpdesk', ['TicketCC'])

        # Adding model 'CustomField'
        db.create_table('helpdesk_customfield', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('name', self.gf('django.db.models.fields.SlugField')(max_length=50, unique=True, db_index=True)),
            ('label', self.gf('django.db.models.fields.CharField')(max_length='30')),
            ('help_text', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
            ('data_type', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('max_length', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True)),
            ('decimal_places', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True)),
            ('list_values', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
            ('required', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('staff_only', self.gf('django.db.models.fields.BooleanField')(default=False)),
        ))
        db.send_create_signal('helpdesk', ['CustomField'])

        # Adding model 'TicketCustomFieldValue'
        db.create_table('helpdesk_ticketcustomfieldvalue', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('ticket', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['helpdesk.Ticket'])),
            ('field', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['helpdesk.CustomField'])),
            ('value', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
        ))
        db.send_create_signal('helpdesk', ['TicketCustomFieldValue'])

        # Adding unique constraint on 'TicketCustomFieldValue', fields ['ticket', 'field']
        db.create_unique('helpdesk_ticketcustomfieldvalue', ['ticket_id', 'field_id'])

0 View Complete Implementation : test_converter.py
Copyright MIT License
Author : graphql-python
def test_should_auto_convert_id():
    astert_conversion(models.AutoField, graphene.ID, primary_key=True)

0 View Complete Implementation : 0001_initial.py
Copyright BSD 2-Clause "Simplified" License
Author : evrenesat
    def forwards(self, orm):
        
        # Adding model 'Dil'
        db.create_table('website_dil', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('etkin', self.gf('django.db.models.fields.BooleanField')(default=True)),
            ('pul', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
            ('adi', self.gf('django.db.models.fields.CharField')(max_length=30)),
            ('kodu', self.gf('django.db.models.fields.CharField')(max_length=5)),
        ))
        db.send_create_signal('website', ['Dil'])

        # Adding model 'Kelime'
        db.create_table('website_kelime', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('kelime', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('durum', self.gf('django.db.models.fields.SmallIntegerField')(default=0)),
            ('timestamp', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
        ))
        db.send_create_signal('website', ['Kelime'])

        # Adding model 'Ceviriler'
        db.create_table('website_ceviriler', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('kelime', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['website.Kelime'])),
            ('asil', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('kod', self.gf('django.db.models.fields.CharField')(max_length=5)),
            ('dil', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['website.Dil'])),
            ('ceviri', self.gf('django.db.models.fields.TextField')()),
            ('timestamp', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
        ))
        db.send_create_signal('website', ['Ceviriler'])

        # Adding model 'Medya'
        db.create_table('website_medya', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('tip', self.gf('django.db.models.fields.SmallIntegerField')(db_index=True)),
            ('ad', self.gf('django.db.models.fields.CharField')(max_length=185)),
            ('dil', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['website.Dil'], null=True, blank=True)),
            ('pul', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
            ('sablon', self.gf('django.db.models.fields.CharField')(max_length=200, null=True, blank=True)),
            ('etkin', self.gf('django.db.models.fields.BooleanField')(default=True, db_index=True)),
            ('dosya', self.gf('django.db.models.fields.files.FileField')(max_length=100)),
            ('dil_kodu', self.gf('django.db.models.fields.CharField')(max_length=5)),
        ))
        db.send_create_signal('website', ['Medya'])

        # Adding model 'Sayfa'
        db.create_table('website_sayfa', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('parent', self.gf('mptt.fields.TreeForeignKey')(blank=True, related_name='children', null=True, to=orm['website.Sayfa'])),
            ('pul', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
            ('sablon', self.gf('django.db.models.fields.CharField')(max_length=200, null=True, blank=True)),
            ('menude', self.gf('django.db.models.fields.BooleanField')(default=True)),
            ('etkin', self.gf('django.db.models.fields.BooleanField')(default=True)),
            ('sadece_uyeler', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('lft', self.gf('django.db.models.fields.PositiveIntegerField')(db_index=True)),
            ('rght', self.gf('django.db.models.fields.PositiveIntegerField')(db_index=True)),
            ('tree_id', self.gf('django.db.models.fields.PositiveIntegerField')(db_index=True)),
            ('level', self.gf('django.db.models.fields.PositiveIntegerField')(db_index=True)),
        ))
        db.send_create_signal('website', ['Sayfa'])

        # Adding M2M table for field medya on 'Sayfa'
        db.create_table('website_sayfa_medya', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('sayfa', models.ForeignKey(orm['website.sayfa'], null=False)),
            ('medya', models.ForeignKey(orm['website.medya'], null=False))
        ))
        db.create_unique('website_sayfa_medya', ['sayfa_id', 'medya_id'])

        # Adding model 'Icerik'
        db.create_table('website_icerik', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('dil', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['website.Dil'])),
            ('dil_kodu', self.gf('django.db.models.fields.CharField')(max_length=5, db_index=True)),
            ('metin', self.gf('tinymce.models.HTMLField')(null=True, blank=True)),
            ('baslik', self.gf('django.db.models.fields.CharField')(max_length=255)),
            ('menu_baslik', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)),
            ('slug', self.gf('django.db.models.fields.SlugField')(max_length=255, db_index=True)),
            ('url', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=255, null=True, blank=True)),
            ('tanim', self.gf('django.db.models.fields.TextField')(max_length=255, null=True, blank=True)),
            ('anahtar', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)),
            ('html_baslik', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)),
            ('sayfa', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['website.Sayfa'])),
            ('olusturma', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)),
            ('guncelleme', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, null=True, blank=True)),
        ))
        db.send_create_signal('website', ['Icerik'])

        # Adding unique constraint on 'Icerik', fields ['dil', 'sayfa']
        db.create_unique('website_icerik', ['dil_id', 'sayfa_id'])

        # Adding model 'Haber'
        db.create_table('website_haber', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('dil', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['website.Dil'])),
            ('dil_kodu', self.gf('django.db.models.fields.CharField')(max_length=5, db_index=True)),
            ('baslik', self.gf('django.db.models.fields.CharField')(max_length=200)),
            ('slug', self.gf('django.db.models.fields.SlugField')(max_length=50, db_index=True)),
            ('anahtar_kelime', self.gf('django.db.models.fields.CharField')(max_length=250, null=True, blank=True)),
            ('tanim', self.gf('django.db.models.fields.CharField')(max_length=100, null=True, blank=True)),
            ('icerik', self.gf('tinymce.models.HTMLField')()),
            ('pul', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
            ('son_guncelleme', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, null=True, blank=True)),
            ('etkin', self.gf('django.db.models.fields.BooleanField')(default=True)),
            ('sabit', self.gf('django.db.models.fields.BooleanField')(default=False)),
        ))
        db.send_create_signal('website', ['Haber'])

        # Adding M2M table for field medya on 'Haber'
        db.create_table('website_haber_medya', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('haber', models.ForeignKey(orm['website.haber'], null=False)),
            ('medya', models.ForeignKey(orm['website.medya'], null=False))
        ))
        db.create_unique('website_haber_medya', ['haber_id', 'medya_id'])

        # Adding model 'Vitrin'
        db.create_table('website_vitrin', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('banner', self.gf('django.db.models.fields.SmallIntegerField')()),
            ('dil', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['website.Dil'], null=True, blank=True)),
            ('dil_kodu', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=5, null=True, blank=True)),
            ('gorsel', self.gf('django.db.models.fields.files.ImageField')(max_length=100, null=True, blank=True)),
            ('pul', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
            ('etkin', self.gf('django.db.models.fields.BooleanField')(default=True)),
            ('sira', self.gf('django.db.models.fields.SmallIntegerField')(db_index=True)),
        ))
        db.send_create_signal('website', ['Vitrin'])

0 View Complete Implementation : 0002_auto__add_project__add_unique_project_name_organization.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
    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'])

0 View Complete Implementation : inspectors.py
Copyright Apache License 2.0
Author : BeanWei
def field_to_schema(field):
    satle = force_text(field.label) if field.label else ''
    description = force_text(field.help_text) if field.help_text else ''

    if isinstance(field, (serializers.ListSerializer, serializers.ListField)):
        child_schema = field_to_schema(field.child)
        return coreschema.Array(
            items=child_schema,
            satle=satle,
            description=description
        )
    elif isinstance(field, serializers.DictField):
        return coreschema.Object(
            satle=satle,
            description=description
        )
    elif isinstance(field, serializers.Serializer):
        return coreschema.Object(
            properties=OrderedDict([
                (key, field_to_schema(value))
                for key, value
                in field.fields.items()
            ]),
            satle=satle,
            description=description
        )
    elif isinstance(field, serializers.ManyRelatedField):
        return coreschema.Array(
            items=coreschema.String(),
            satle=satle,
            description=description
        )
    elif isinstance(field, serializers.PrimaryKeyRelatedField):
        schema_cls = coreschema.String
        model = getattr(field.queryset, 'model', None)
        if model is not None:
            model_field = model._meta.pk
            if isinstance(model_field, models.AutoField):
                schema_cls = coreschema.Integer
        return schema_cls(satle=satle, description=description)
    elif isinstance(field, serializers.RelatedField):
        return coreschema.String(satle=satle, description=description)
    elif isinstance(field, serializers.MultipleChoiceField):
        return coreschema.Array(
            items=coreschema.Enum(enum=list(field.choices)),
            satle=satle,
            description=description
        )
    elif isinstance(field, serializers.ChoiceField):
        return coreschema.Enum(
            enum=list(field.choices),
            satle=satle,
            description=description
        )
    elif isinstance(field, serializers.BooleanField):
        return coreschema.Boolean(satle=satle, description=description)
    elif isinstance(field, (serializers.DecimalField, serializers.FloatField)):
        return coreschema.Number(satle=satle, description=description)
    elif isinstance(field, serializers.IntegerField):
        return coreschema.Integer(satle=satle, description=description)
    elif isinstance(field, serializers.DateField):
        return coreschema.String(
            satle=satle,
            description=description,
            format='date'
        )
    elif isinstance(field, serializers.DateTimeField):
        return coreschema.String(
            satle=satle,
            description=description,
            format='date-time'
        )

    if field.style.get('base_template') == 'textarea.html':
        return coreschema.String(
            satle=satle,
            description=description,
            format='textarea'
        )
    return coreschema.String(satle=satle, description=description)

0 View Complete Implementation : inspectors.py
Copyright Apache License 2.0
Author : BeanWei
    def get_path_fields(self, path, method):
        """
        Return a list of `coreapi.Field` instances corresponding to any
        templated path variables.
        """
        view = self.view
        model = getattr(getattr(view, 'queryset', None), 'model', None)
        fields = []

        for variable in uritemplate.variables(path):
            satle = ''
            description = ''
            schema_cls = coreschema.String
            kwargs = {}
            if model is not None:
                # Attempt to infer a field description if possible.
                try:
                    model_field = model._meta.get_field(variable)
                except Exception:
                    model_field = None

                if model_field is not None and model_field.verbose_name:
                    satle = force_text(model_field.verbose_name)

                if model_field is not None and model_field.help_text:
                    description = force_text(model_field.help_text)
                elif model_field is not None and model_field.primary_key:
                    description = get_pk_description(model, model_field)

                if hasattr(view, 'lookup_value_regex') and view.lookup_field == variable:
                    kwargs['pattern'] = view.lookup_value_regex
                elif isinstance(model_field, models.AutoField):
                    schema_cls = coreschema.Integer

            field = coreapi.Field(
                name=variable,
                location='path',
                required=True,
                schema=schema_cls(satle=satle, description=description, **kwargs)
            )
            fields.append(field)

        return fields

0 View Complete Implementation : wizard.py
Copyright Apache License 2.0
Author : BeanWei
    def _done(self):
        cleaned_data = self.get_all_cleaned_data()
        exclude = self.admin_view.exclude

        opts = self.admin_view.opts
        instance = self.admin_view.org_obj or self.admin_view.model()

        file_field_list = []
        for f in opts.fields:
            if not f.editable or isinstance(f, models.AutoField) \
                    or not f.name in cleaned_data:
                continue
            if exclude and f.name in exclude:
                continue
            # Defer saving file-type fields until after the other fields, so a
            # callable upload_to can use the values from other fields.
            if isinstance(f, models.FileField):
                file_field_list.append(f)
            else:
                f.save_form_data(instance, cleaned_data[f.name])

        for f in file_field_list:
            f.save_form_data(instance, cleaned_data[f.name])

        instance.save()

        for f in opts.many_to_many:
            if f.name in cleaned_data:
                f.save_form_data(instance, cleaned_data[f.name])

        self.admin_view.new_obj = instance

0 View Complete Implementation : base.py
Copyright GNU General Public License v2.0
Author : blackye
    def sequence_reset_sql(self, style, model_list):
        from django.db import models
        output = []
        query = _get_sequence_reset_sql()
        for model in model_list:
            for f in model._meta.local_fields:
                if isinstance(f, models.AutoField):
                    table_name = self.quote_name(model._meta.db_table)
                    sequence_name = self._get_sequence_name(model._meta.db_table)
                    column_name = self.quote_name(f.column)
                    output.append(query % {'sequence': sequence_name,
                                           'table': table_name,
                                           'column': column_name})
                    # Only one AutoField is allowed per model, so don't
                    # continue to loop
                    break
            for f in model._meta.many_to_many:
                if not f.rel.through:
                    table_name = self.quote_name(f.m2m_db_table())
                    sequence_name = self._get_sequence_name(f.m2m_db_table())
                    column_name = self.quote_name('id')
                    output.append(query % {'sequence': sequence_name,
                                           'table': table_name,
                                           'column': column_name})
        return output

0 View Complete Implementation : operations.py
Copyright GNU General Public License v2.0
Author : blackye
    def sequence_reset_sql(self, style, model_list):
        from django.db import models
        output = []
        qn = self.quote_name
        for model in model_list:
            # Use `coalesce` to set the sequence for each model to the max pk value if there are records,
            # or 1 if there are none. Set the `is_called` property (the third argument to `setval`) to true
            # if there are records (as the max pk value is already in use), otherwise set it to false.
            # Use pg_get_serial_sequence to get the underlying sequence name from the table name
            # and column name (available since PostgreSQL 8)

            for f in model._meta.local_fields:
                if isinstance(f, models.AutoField):
                    output.append("%s setval(pg_get_serial_sequence('%s','%s'), coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \
                        (style.SQL_KEYWORD('SELECT'),
                        style.SQL_TABLE(qn(model._meta.db_table)),
                        style.SQL_FIELD(f.column),
                        style.SQL_FIELD(qn(f.column)),
                        style.SQL_FIELD(qn(f.column)),
                        style.SQL_KEYWORD('IS NOT'),
                        style.SQL_KEYWORD('FROM'),
                        style.SQL_TABLE(qn(model._meta.db_table))))
                    break # Only one AutoField is allowed per model, so don't bother continuing.
            for f in model._meta.many_to_many:
                if not f.rel.through:
                    output.append("%s setval(pg_get_serial_sequence('%s','%s'), coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \
                        (style.SQL_KEYWORD('SELECT'),
                        style.SQL_TABLE(qn(f.m2m_db_table())),
                        style.SQL_FIELD('id'),
                        style.SQL_FIELD(qn('id')),
                        style.SQL_FIELD(qn('id')),
                        style.SQL_KEYWORD('IS NOT'),
                        style.SQL_KEYWORD('FROM'),
                        style.SQL_TABLE(qn(f.m2m_db_table()))))
        return output