コード例 #1
0
class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='PropertyType',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=42)),
                ('name_en', models.CharField(max_length=42, null=True)),
                ('name_ru', models.CharField(max_length=42, null=True)),
                ('name_pl', models.CharField(max_length=42, null=True)),
                ('name_uk', models.CharField(max_length=42, null=True)),
            ],
        ),
        migrations.CreateModel(
            name='Rental',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
                ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
                ('title', models.CharField(max_length=255, verbose_name='title')),
                ('description', models.TextField(blank=True, null=True, verbose_name='description')),
                ('slug', django_extensions.db.fields.AutoSlugField(blank=True, editable=False, populate_from='title', verbose_name='slug')),
                ('expires', models.DateField(blank=True, help_text='Format mm/dd/yyyy', null=True, validators=[adverts.models.validate_expires], verbose_name='expires')),
                ('local', models.CharField(choices=[('en', 'en_US'), ('uk', 'uk_UA'), ('ru', 'ru_RU'), ('pl', 'pl_PL')], default='en', max_length=2)),
                ('city', models.CharField(default='Chicago', max_length=50, verbose_name='city')),
                ('address', models.CharField(blank=True, max_length=100, verbose_name='address')),
                ('point', django.contrib.gis.db.models.fields.PointField(blank=True, geography=True, null=True, srid=4326, verbose_name='map')),
                ('image', models.ImageField(blank=True, null=True, upload_to=adverts.models.user_directory_path)),
                ('bathrooms', models.PositiveSmallIntegerField(default=1)),
                ('bedrooms', models.PositiveSmallIntegerField(default=1)),
                ('price', models.PositiveIntegerField()),
                ('pet_policy', models.PositiveSmallIntegerField(choices=[(0, 'None'), (1, 'Dogs'), (2, 'Cats'), (3, 'Dogs and Cats'), (4, 'Any')], default=0)),
                ('furnished', models.BooleanField()),
                ('prefer_sex', models.CharField(choices=[('a', 'any'), ('w', 'woman'), ('m', 'man')], default='a', max_length=1)),
                ('author', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='author')),
                ('favourites', models.ManyToManyField(blank=True, default=None, related_name='favourite_rents', to=settings.AUTH_USER_MODEL)),
                ('property_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rents.PropertyType', verbose_name='property type')),
            ],
            options={
                'ordering': ['modified'],
                'abstract': False,
            },
        ),
    ]
コード例 #2
0
ファイル: 0001_initial.py プロジェクト: zfazylz/booktobook
class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='Advert',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=100)),
                ('description', models.TextField()),
                ('price', models.IntegerField()),
                ('image', models.FileField(blank=True, null=True, upload_to=adverts.models.get_upload_file_name)),
                ('location', models.CharField(max_length=50)),
                ('pub_date', models.DateField(auto_now_add=True)),
            ],
        ),
        migrations.CreateModel(
            name='Category',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('category', models.CharField(max_length=40)),
            ],
        ),
        migrations.CreateModel(
            name='Comment',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('text', models.TextField()),
                ('advert', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='adverts.Advert')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.AddField(
            model_name='advert',
            name='category',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='adverts.Category'),
        ),
        migrations.AddField(
            model_name='advert',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
        ),
    ]
コード例 #3
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='Product',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(db_index=True, max_length=200)),
                ('slug', models.SlugField(max_length=200)),
                ('image',
                 models.ImageField(
                     blank=True,
                     upload_to=adverts.models.user_directory_path)),
                ('description', models.TextField(blank=True)),
                ('price', models.DecimalField(decimal_places=2,
                                              max_digits=10)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('updated', models.DateTimeField(auto_now=True)),
            ],
            options={
                'ordering': ('name', ),
                'index_together': {('id', 'slug')},
            },
        ),
    ]
コード例 #4
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='AdvertCategories',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
                ('icon', models.ImageField(blank=True, null=True, upload_to=adverts.models.get_image_path)),
            ],
        ),
        migrations.CreateModel(
            name='AdvertRating',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('score', models.SmallIntegerField(choices=[(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)])),
            ],
        ),
        migrations.CreateModel(
            name='Advert',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('exp_date', models.DateTimeField(verbose_name='expiration_date')),
                ('start_date', models.DateTimeField(verbose_name='start_date')),
                ('title', models.CharField(max_length=150)),
                ('description', models.CharField(max_length=500)),
                ('profile_image', models.ImageField(blank=True, null=True, upload_to=adverts.models.get_image_path)),
                ('premium', models.BooleanField(default=False)),
                ('category', models.ManyToManyField(to='adverts.AdvertCategories')),
            ],
        ),
    ]
コード例 #5
0
class Migration(migrations.Migration):

    dependencies = [
        ('adverts', '0002_auto_20170219_1612'),
    ]

    operations = [
        migrations.AlterModelOptions(
            name='images',
            options={
                'verbose_name': 'Zdjęcie',
                'verbose_name_plural': 'Zdjęcia'
            },
        ),
        migrations.AddField(
            model_name='images',
            name='advert',
            field=models.ForeignKey(
                default=None,
                on_delete=django.db.models.deletion.CASCADE,
                related_name='images',
                to='adverts.Advert'),
        ),
        migrations.AlterField(
            model_name='advert',
            name='estate',
            field=models.CharField(choices=[('plot', 'Działka'),
                                            ('investment', 'Inwestycja'),
                                            ('flat', 'Mieszkanie'),
                                            ('house', 'Dom')],
                                   max_length=12,
                                   verbose_name='Typ nieruchomości'),
        ),
        migrations.AlterField(
            model_name='images',
            name='image',
            field=models.ImageField(height_field='height_field',
                                    upload_to=adverts.models.upload_directory,
                                    verbose_name='Zdjęcie',
                                    width_field='width_field'),
        ),
    ]
コード例 #6
0
class Migration(migrations.Migration):

    dependencies = [
        ('adverts', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Images',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('height_field', models.IntegerField(default=0)),
                ('width_field', models.IntegerField(default=0)),
                ('image',
                 models.ImageField(
                     height_field=models.IntegerField(default=0),
                     upload_to=adverts.models.upload_directory,
                     verbose_name='Zdjęcie',
                     width_field=models.IntegerField(default=0))),
            ],
        ),
        migrations.AlterField(
            model_name='advert',
            name='estate',
            field=models.CharField(choices=[('house', 'Dom'),
                                            ('plot', 'Działka'),
                                            ('flat', 'Mieszkanie'),
                                            ('investment', 'Inwestycja')],
                                   max_length=12,
                                   verbose_name='Typ nieruchomości'),
        ),
    ]
コード例 #7
0
class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='Item',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('created',
                 django_extensions.db.fields.CreationDateTimeField(
                     auto_now_add=True, verbose_name='created')),
                ('modified',
                 django_extensions.db.fields.ModificationDateTimeField(
                     auto_now=True, verbose_name='modified')),
                ('title', models.CharField(max_length=255,
                                           verbose_name='title')),
                ('description',
                 models.TextField(blank=True,
                                  null=True,
                                  verbose_name='description')),
                ('slug',
                 django_extensions.db.fields.AutoSlugField(
                     blank=True,
                     editable=False,
                     populate_from='title',
                     verbose_name='slug')),
                ('expires',
                 models.DateField(blank=True,
                                  help_text='Format mm/dd/yyyy',
                                  null=True,
                                  validators=[adverts.models.validate_expires],
                                  verbose_name='expires')),
                ('local',
                 models.CharField(choices=[('en', 'en_US'), ('uk', 'uk_UA'),
                                           ('ru', 'ru_RU'), ('pl', 'pl_PL')],
                                  default='en',
                                  max_length=2)),
                ('city',
                 models.CharField(default='Chicago',
                                  max_length=50,
                                  verbose_name='city')),
                ('address',
                 models.CharField(blank=True,
                                  max_length=100,
                                  verbose_name='address')),
                ('point',
                 django.contrib.gis.db.models.fields.PointField(
                     blank=True,
                     geography=True,
                     null=True,
                     srid=4326,
                     verbose_name='map')),
                ('condition',
                 models.CharField(choices=[('0', 'Used'), ('1', 'Acceptable'),
                                           ('2', 'Very Good'),
                                           ('3', 'Like New'), ('4', 'New')],
                                  default='0',
                                  max_length=1,
                                  verbose_name='condition')),
                ('image',
                 sorl.thumbnail.fields.ImageField(
                     blank=True,
                     null=True,
                     upload_to=adverts.models.user_directory_path)),
                ('price',
                 models.DecimalField(decimal_places=2,
                                     max_digits=10,
                                     verbose_name='price')),
                ('author',
                 models.ForeignKey(null=True,
                                   on_delete=django.db.models.deletion.CASCADE,
                                   to=settings.AUTH_USER_MODEL,
                                   verbose_name='author')),
                ('favourites',
                 models.ManyToManyField(blank=True,
                                        default=None,
                                        related_name='favourite_items',
                                        to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['modified'],
                'abstract': False,
            },
        ),
    ]