Skip to content

Instantly share code, notes, and snippets.

@russell310
Created April 20, 2020 14:35
Show Gist options
  • Select an option

  • Save russell310/22fa7f9329a458467d4bcd99e917c86c to your computer and use it in GitHub Desktop.

Select an option

Save russell310/22fa7f9329a458467d4bcd99e917c86c to your computer and use it in GitHub Desktop.
Sometime needs to delete all migration file in django here is how you will reset migrations file
import os
import glob
dot_py = glob.glob('*/migrations/*.py', recursive=True)
for filePath in dot_py:
if not os.path.basename(filePath) == '__init__.py':
try:
os.remove(filePath)
except OSError:
print("Error while deleting file")
dot_pyc = glob.glob('*/migrations/*.pyc', recursive=True)
for filePath in dot_pyc:
try:
os.remove(filePath)
except OSError:
print("Error while deleting file")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment