Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django migration - disable system checks

I upgraded from Django 1.7 to Django 1.9. I have a number of migrations. Since the upgrade I can no longer create a fresh database.

The problem is that "django manage.py migrate" runs checks. The checks import the application urls. These ultimately import code that looks up the database.

I can get the migration to work, by modifying the migrate.py script and adding this line (as per Django: skip system check when running custom command):

 requires_system_checks = False

Is there a standard/supported way to prevent the system checks via a command line parameter, or is there a way to know that I am running in a management command during the url loading so that I can exclude the web-serving parts of the system?

like image 533
Kevin Gill Avatar asked Mar 04 '16 09:03

Kevin Gill


People also ask

How do I fix migration issues in Django?

you can either: temporarily remove your migration, execute python manage.py migrate, add again your migration and re-execute python manage.py migrate. Use this case if the migrations refer to different models and you want different migration files for each one of them.

How do I stop migrations in Django?

You can selectively disable migration for one or more Django-Models by setting managed = False in Django Model Meta options. Save this answer.

What is difference between migrate and Makemigrations in Django?

migrate , which is responsible for applying and unapplying migrations. makemigrations , which is responsible for creating new migrations based on the changes you have made to your models.

Why Makemigrations is not working?

You don't have migrations folder inside those apps. (Solution: just create that folder). You don't have __init__.py file inside migrations folder of those apps. (Solution: Just create an empty file with name __init__.py )


1 Answers

There is a way in the 3.0 version, there is a flag called --skip-checks which skips running system checks prior to running the command.

like image 102
Davit Tovmasyan Avatar answered Nov 03 '22 18:11

Davit Tovmasyan