M
M
mugiwara_l2018-03-13 22:55:30
Django
mugiwara_l, 2018-03-13 22:55:30

Python Django not working change in sqllite database, what is the error?

Greetings!
As part of a tutorial project, I'm experimenting with migrations in django. The task is to change the data in an existing table in one of the columns. sqllite database. According to the documentation https://docs.djangoproject.com/en/2.0/topics/migra... I create an empty migration. I write my own function in it. I'm running the migration. The migration is running successfully. The data in the database does not change. I tried several times - the result is zero. If I delete something, add it to the models, then the migrations are performed without problems. But there is no way to change the data. Below is the migration code....

# Generated by Django 2.0.2 on 2018-03-13 19:18

from django.db import migrations

def combine(apps, schema_editor):
    Comments = apps.get_model('article', 'Comments')
    for comment in Comments.objects.all():
        comment.comments_test = 'hello-world'
        comment.save

class Migration(migrations.Migration):

    dependencies = [
        ('article', '0021_auto_20180312_2238'),
    ]

    operations = [
        migrations.RunPython(combine),
    ]

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