20👍
Your script appears to be the problem. It is trying to delete your migrations, but it’s actually also deleting the contents of Django’s /django/db/migrations/
file as well. Note that it explicitly doesn’t delete the __init__.py
file but it does delete the others.
One option is just to remove these lines:
echo ">> Deleting old migrations"
find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
find . -path "*/migrations/*.pyc" -delete
You shouldn’t be deleting old migrations anyway once you’re running Django on production because you might want to add custom code to a migration. This looks like a convenience script for development.
30👍
If your error still like :
from .migration import Migration, swappable_dependency # NOQA
ImportError: No module named 'django.db.migrations.migration'
You need to reinstall dajngo
Check You Django version and then Force Reinstall it
python -m django --version
pip install –upgrade –force-reinstall package
pip install --upgrade --force-reinstall Django==2.0.5
- Django Formset.is_valid() failing for extra forms
- Custom unique_together key name
- Creating readable html with django templates
- Return list of objects as dictionary with keys as the objects id with django rest framerwork
5👍
As @YPCrumble pointed out, your “>> Deleting old migrations” script deleted /django/db/migrations/
file as well. To restore it back, you need to uninstall Django and reinstall it.
3👍
Just reinstall the django version or upgrade the version. This solves my problem.
pip install --upgrade django==1.11.18
Then makemigrations
- How to create a django ViewFlow process programmatically
- Ignoring case with __startswith
- How to upload folder on Google Cloud Storage using Python API
- Is there such a thing for Django as there is Heroku for Ruby on Rails
2👍
You must have deleted the migrations file
In that case try force reinstalling Django:
pip install --upgrade --force-reinstall Django
- How to get average from set of objects in Django?
- What is Django's TEMPLATE_DEBUG setting for?
- Override serializer.data in Django REST Framework
- Registered models do not show up in admin
1👍
Django models has a manage attribute.It can manage database table create or not create.manage is false not create database table, manage is true create tabe.
Class User(models.Model):
username = models.CharField(max_length=255)
Class Meta:
manage = False
manage = True
- Drop database and create new database.
- Update settings file (database connection).
- Delete exist migrations files.
- Create new migrations.
- Run new migrations.
- Took too long to shut down and was killed
- How to move model to the other section in Django's site admin
- Spurious newlines added in Django management commands
0👍
Try to place your virtualenv repository outside of your project. Or run the script in a path with it does not include your virtualenv repository.
Or you can exclude virtualenv repository from your find path. Check How to exclude a directory in find . command
- Cross platform interface for virtualenv
- Django – Disable form select field validation
- Pointing to multiple S3 buckets in s3boto
- Django how to override clean() method in a subclass of custom form?