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 : 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 : 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 : 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 : 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 : 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 : 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 : 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 : 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 : 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 : 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,
    )