django-migrations

Django migration delete and update

狂风中的少年 提交于 2020-07-23 11:33:24
问题 I have already had some migration files, and I made some changes in the model and did python manage.py makemigrations python manage.py migrate After that in postgresql table django_migrations there is a row indicating I've applied that migration, let's call this migrationA. I deleted the new generated migration file (migrationA), modified a small piece in my model and then did python manage.py makemigrations python manage.py migrate This generate migrationB. I was hoping this can do the same

Django migration delete and update

拥有回忆 提交于 2020-07-23 11:33:07
问题 I have already had some migration files, and I made some changes in the model and did python manage.py makemigrations python manage.py migrate After that in postgresql table django_migrations there is a row indicating I've applied that migration, let's call this migrationA. I deleted the new generated migration file (migrationA), modified a small piece in my model and then did python manage.py makemigrations python manage.py migrate This generate migrationB. I was hoping this can do the same

Django migration delete and update

余生长醉 提交于 2020-07-23 11:31:07
问题 I have already had some migration files, and I made some changes in the model and did python manage.py makemigrations python manage.py migrate After that in postgresql table django_migrations there is a row indicating I've applied that migration, let's call this migrationA. I deleted the new generated migration file (migrationA), modified a small piece in my model and then did python manage.py makemigrations python manage.py migrate This generate migrationB. I was hoping this can do the same

Provide a default for ForeignKey field on existing entries in Django

落爺英雄遲暮 提交于 2020-07-04 13:18:08
问题 I have this model: class Movie(models.Model): # here are some fields for this model to which I added the following field (the database was already populated with Movie models): user = models.ForeignKey(User, default=1) I ran the commands 'makemigrations' and then 'migrate': python manage.py makemigrations myapp python manage.py migrate but it doesn't work. What I want to do is to add the 'user' field to Movie objects and provide a default for it for all the existing Movie objects in my

What is Django's migration?

隐身守侯 提交于 2020-06-08 20:05:22
问题 I've been wrapping my head around this concept for a while, when I start a new django project, it urges me to apply migrations: # python manage.py runserver Performing system checks... System check identified no issues (0 silenced). You have 13 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run 'python manage.py migrate' to apply them. why do I need to do it? could anybody give a concise explanation

Can I delete the django migration files inside migrations directory

蹲街弑〆低调 提交于 2020-05-25 06:46:07
问题 I personally like django for its MVC ideals. But while i am running Django migrations in version 1.7 each and every migrations i do in it is stored inside the migrations directory. If i delete those file it is throwing an error while migration. I Tested like this. I created a new Django project and initiated a git repo . I ran some 3-4 migrations in Django which resulted in 3-4 migration files under the migrations directory. I tried deleting the very older migration files i.e (1st and 2nd

Django no such table: django_site after deleting migrations and database

空扰寡人 提交于 2020-05-17 04:20:38
问题 I tried to change an app name. This didnt work and so I tried to change it back. This didnt work either and I deleted all migrations and my db.sqlite. Now whenever I try makemigrations or migrate I get this error: django.db.utils.OperationalError: no such table: django_site full traceback: Traceback (most recent call last): File "C:\Users\Myzel394\Documents\PROGRAMMIEREN\Schule\MGLZeitung\manage.py", line 18, in <module> execute_from_command_line(sys.argv) File "C:\Program Files\Python37\lib

Django no such table: django_site after deleting migrations and database

隐身守侯 提交于 2020-05-17 04:19:23
问题 I tried to change an app name. This didnt work and so I tried to change it back. This didnt work either and I deleted all migrations and my db.sqlite. Now whenever I try makemigrations or migrate I get this error: django.db.utils.OperationalError: no such table: django_site full traceback: Traceback (most recent call last): File "C:\Users\Myzel394\Documents\PROGRAMMIEREN\Schule\MGLZeitung\manage.py", line 18, in <module> execute_from_command_line(sys.argv) File "C:\Program Files\Python37\lib