V
V
valexeich2022-04-04 20:06:54
Django
valexeich, 2022-04-04 20:06:54

Some fields are not added to makemigrations, what should I do?

When I make migrations, some fields are not added to me

Here is my model

class Post(models.Model):
    author = models.ForeignKey(Profile, on_delete=models.CASCADE, related_name='post'),
    liked = models.ManyToManyField(Profile, default=None, related_name='likes'),
    disliked = models.ManyToManyField(Profile, default=None, related_name='dislikes'),
    text = models.TextField()
    image = models.ImageField(
        upload_to='post_image',
        validators=[FileExtensionValidator(['png', 'jpg', 'jpeg'])],
        blank=True
    )
    video = models.FileField(
        upload_to='post_video/',
        validators=[FileExtensionValidator(['mp4'])],
        blank=True
    )
    updated_date = models.DateTimeField(auto_now=True)
    created_date = models.DateTimeField(auto_now_add=True)


When I do makemigrations it doesn't add the author, liked, disliked fields, and as a result I don't have these fields. How to fix it? I will be glad for any help.

migrations.CreateModel(
            name='Post',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('text', models.TextField()),
                ('image', models.ImageField(blank=True, upload_to='post_image', validators=[django.core.validators.FileExtensionValidator(['png', 'jpg', 'jpeg'])])),
                ('video', models.FileField(blank=True, upload_to='post_video/', validators=[django.core.validators.FileExtensionValidator(['mp4'])])),
                ('updated_date', models.DateTimeField(auto_now=True)),
                ('created_date', models.DateTimeField(auto_now_add=True)),
            ],
        ),

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question