예제 #1
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='Post',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('title', models.CharField(max_length=200)),
                ('content', models.TextField()),
                ('updated', models.DateTimeField(auto_now=True)),
                ('timestamp', models.DateTimeField(auto_now_add=True)),
                ('image',
                 models.ImageField(blank=True,
                                   height_field='height_field',
                                   null=True,
                                   upload_to=article.models.upload_location,
                                   width_field='width_field')),
                ('height_field', models.IntegerField(default=0)),
                ('width_field', models.IntegerField(default=0)),
                ('slug', models.SlugField(unique=True)),
            ],
        ),
    ]
예제 #2
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='Article',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('article_title', models.CharField(max_length=200)),
                ('browser_url', models.SlugField(default='', max_length=150)),
                ('article_image',
                 models.ImageField(blank=True,
                                   default='no_image.png',
                                   max_length=150,
                                   upload_to=article.models.upload_image_path,
                                   verbose_name='Изображения')),
                ('article_text', models.TextField()),
                ('article_date', models.DateTimeField()),
                ('article_likes', models.IntegerField(default=0)),
            ],
            options={
                'db_table': 'article',
            },
        ),
        migrations.CreateModel(
            name='Comments',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('comments_text', models.TextField()),
                ('comments_article',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='article.Article')),
            ],
            options={
                'db_table': 'comments',
            },
        ),
    ]
예제 #3
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Article',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('title', models.CharField(max_length=150,
                                           verbose_name='文章标题')),
                ('slug', models.SlugField(max_length=250, unique=True)),
                ('summary',
                 models.TextField(default='文章摘要等同于网页description内容,请务必填写...',
                                  max_length=230,
                                  verbose_name='文章摘要')),
                ('body', mdeditor.fields.MDTextField(verbose_name='文章内容')),
                ('image',
                 models.ImageField(
                     upload_to=article.models.articleimage_directory_path,
                     verbose_name='图片')),
                ('create_date',
                 models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('update_date',
                 models.DateTimeField(auto_now=True, verbose_name='修改时间')),
                ('views', models.IntegerField(default=0, verbose_name='阅览量')),
                ('likes', models.PositiveIntegerField(default=0)),
                ('is_top', models.BooleanField(default=False,
                                               verbose_name='置顶')),
                ('author',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to=settings.AUTH_USER_MODEL,
                                   verbose_name='作者')),
            ],
            options={
                'verbose_name': '文章',
                'verbose_name_plural': '文章',
                'ordering': ['-create_date'],
            },
        ),
        migrations.CreateModel(
            name='Carousel',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('number',
                 models.IntegerField(help_text='编号决定图片播放的顺序,图片不要多于5张',
                                     verbose_name='编号')),
                ('title',
                 models.CharField(blank=True,
                                  help_text='标题可以为空',
                                  max_length=20,
                                  null=True,
                                  verbose_name='标题')),
                ('content', models.CharField(max_length=80,
                                             verbose_name='描述')),
                ('image',
                 models.ImageField(upload_to='banner/%Y%m',
                                   verbose_name='轮播图')),
                ('url',
                 models.CharField(default='#',
                                  help_text='图片跳转的超链接,默认#表示不跳转',
                                  max_length=256,
                                  verbose_name='跳转链接')),
            ],
            options={
                'verbose_name': '图片轮播',
                'verbose_name_plural': '图片轮播',
                'ordering': ['number', '-id'],
            },
        ),
        migrations.CreateModel(
            name='Category',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=20, verbose_name='文章分类')),
                ('slug', models.SlugField(unique=True)),
                ('description',
                 models.TextField(help_text='用来作为SEO中description,长度参考SEO标准',
                                  max_length=240,
                                  verbose_name='描述')),
            ],
            options={
                'verbose_name': '分类',
                'verbose_name_plural': '分类',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Course',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=20, verbose_name='教程')),
                ('slug', models.SlugField(unique=True)),
                ('description',
                 models.TextField(help_text='用来作为SEO中description,长度参考SEO标准',
                                  max_length=240,
                                  verbose_name='描述')),
            ],
            options={
                'verbose_name': '教程',
                'verbose_name_plural': '教程',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Keyword',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=20,
                                          verbose_name='文章关键词')),
            ],
            options={
                'verbose_name': '关键词',
                'verbose_name_plural': '关键词',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Tag',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=20, verbose_name='文章标签')),
                ('slug', models.SlugField(unique=True)),
                ('description',
                 models.TextField(help_text='用来作为SEO中description,长度参考SEO标准',
                                  max_length=240,
                                  verbose_name='描述')),
            ],
            options={
                'verbose_name': '标签',
                'verbose_name_plural': '标签',
                'ordering': ['id'],
            },
        ),
        migrations.CreateModel(
            name='Comment',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('body', ckeditor.fields.RichTextField()),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('article',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='article.Article',
                                   verbose_name='文章评论')),
            ],
            options={
                'ordering': ('created', ),
            },
        ),
        migrations.AddField(
            model_name='article',
            name='category',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.PROTECT,
                to='article.Category',
                verbose_name='文章分类'),
        ),
        migrations.AddField(
            model_name='article',
            name='course',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                to='article.Course',
                verbose_name='课程'),
        ),
        migrations.AddField(
            model_name='article',
            name='keywords',
            field=models.ManyToManyField(
                help_text='文章关键词,用来作为SEO中keywords,最好使用长尾词,3-4个足够',
                to='article.Keyword',
                verbose_name='文章关键词'),
        ),
        migrations.AddField(
            model_name='article',
            name='tags',
            field=models.ManyToManyField(to='article.Tag', verbose_name='标签'),
        ),
    ]
예제 #4
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Category',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('category_name',
                 models.CharField(max_length=50, verbose_name='Title')),
                ('category_slug', models.SlugField(max_length=60,
                                                   unique=True)),
            ],
        ),
        migrations.CreateModel(
            name='Post',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('title', models.CharField(max_length=255, unique=True)),
                ('slug', models.SlugField(max_length=270, unique=True)),
                ('thumbnail',
                 models.ImageField(blank=True,
                                   upload_to=article.models.post_thumb_path)),
                ('content', models.TextField()),
                ('updated_on', models.DateTimeField(auto_now=True)),
                ('created_on', models.DateTimeField(auto_now_add=True)),
                ('status',
                 models.IntegerField(choices=[(0, 'Draft'), (1, 'Publish')],
                                     default=1)),
                ('author',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='blog_posts',
                                   to=settings.AUTH_USER_MODEL)),
                ('category',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='article.Category',
                                   verbose_name='Category')),
            ],
            options={
                'ordering': ['-created_on'],
            },
        ),
        migrations.CreateModel(
            name='Comment',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('body', models.TextField()),
                ('updated_on', models.DateTimeField(auto_now=True)),
                ('created_on', models.DateTimeField(auto_now_add=True)),
                ('active', models.BooleanField(default=True)),
                ('name',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='blog_comments',
                                   to=settings.AUTH_USER_MODEL)),
                ('post',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='comments',
                                   to='article.Post')),
            ],
            options={
                'ordering': ['-created_on'],
            },
        ),
    ]
예제 #5
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Category',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('title',
                 models.CharField(max_length=100, verbose_name='Kategori')),
                ('image', models.ImageField(upload_to='articles/categories/')),
                ('slug', models.SlugField(unique=True)),
                ('sorting', models.IntegerField(verbose_name='Sıra')),
            ],
            options={
                'verbose_name': 'Kategori',
                'verbose_name_plural': 'Kategoriler',
                'ordering': ['sorting'],
            },
        ),
        migrations.CreateModel(
            name='Article',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('title',
                 models.CharField(max_length=200,
                                  verbose_name='Makale Başlık')),
                ('content', models.TextField(verbose_name='İçerik')),
                ('created_date', models.DateTimeField(auto_now_add=True)),
                ('updated_date', models.DateTimeField(auto_now=True)),
                ('status',
                 models.IntegerField(choices=[(0, 'Draft'), (1, 'Publish')],
                                     default=0,
                                     verbose_name='Durum')),
                ('image',
                 models.ImageField(
                     upload_to=article.models.upload_article_image,
                     verbose_name='Kapak Resmi')),
                ('slug', models.SlugField(unique=True)),
                ('author',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='article_post',
                                   to=settings.AUTH_USER_MODEL,
                                   verbose_name='Yazar')),
                ('category',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='articles',
                                   to='article.category',
                                   verbose_name='Kategori')),
            ],
            options={
                'verbose_name': 'Makale',
                'verbose_name_plural': 'Makaleler',
                'ordering': ['-created_date'],
            },
        ),
    ]