I am trying to deploy my code in heroku.
While deploying i complete all the steps
but i get error while migrate
i try these command
heroku run python manage.py makemigrations account
While running above command i get
account/migrations/0001_initial.py
- Create model User
but while trying to migrate
I try
heroku run python manage.py migrate account
i get error
raise ValueError("Dependency on app with no migrations: %s" % key[0])
ValueError: Dependency on app with no migrations: account
i also try
heroku run python manage.py makemigrations
heroku run python manage.py migrate
At this time also i get same error
the project is running successfully in localhost
with out any error
I am new to heroku please anyone can help with full instruction
First try to run command heroku run python manage.py showmigrations to see what migrations have been done.
If it returns an empty list, you have to run heroku run python manage.py migrate to migrate the existing migrations.
After that, you can follow the normal procedures in tutorial
python manage.py makemigrations
python manage.py migrate
my case
(heroku.com)
heroku dashboard
↓
app
↓
deploy
↓
Github
↓
Manual deploy
I was able to migrate
Related
I deleted my database and tried to create a new one.
I did:
python manage.py makemigrations
python manage.py migrate
Then I ran python manage.py runserver and it returned
You have 2 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): social_django.
Run 'python manage.py migrate' to apply them.
Then I ran python manage.py migrate and it returned
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions, social_django
Running migrations:
No migrations to apply.
I am using django 3.0.7 and social-auth-app-django 4.0.0
The solution was to disable the environment.
I don't know why.
You can check to see which migrations have been done by viewing your database with whichever program you use to do that. And checking the django_migrations table.
The migrations that need to be applied will still be in the migrations folders for the apps that haven't been updated.
To get them migrated, assuming they're still in your installed_apps in your settings.py, simply delete the migrations (probably __init__.py) from the migrations folders and re-run :
> python manage.py makemigrations
> python manage.py migrate
run the following command on your command prompt:
1.python manage.py migrate
2.python manage.py runserver
I'm following an online tutorial in order to learn Django/Python. I'm using PyCharm Community Edition as my IDE. On Windows 10.
When I run python manage.py startapp myapp at the (venv) prompt in terminal window , no error is shown, and \myapp folder is created with the expected content. However, the file db.sqlite3 is not created, and I can't follow through the rest of the tutorial.
What might be going wrong here?
Thank you very much.
when you start a new django app no database must created.
you can run command
python manage.py migrate
to generate database for your project.
default database is sqlite and stored in file named db.sqlite3
Command python manage.py startapp myapp does not create db.sqlite3.
Run:
python manage.py makemigrations
python manage.py migrate
It will automatically create one if not present.
I want to test django-embed-video from their official git reposiotry Django-embed-video example project.
Here are their instructions:
Example project For easy start with using django-embed-video, you can
take a look at example project. It is located in example_project
directory in root of repository.
Running example project Install requirements:
pip install -r requirements.txt
Create database:
python manage.py migrate --run-syncdb --noinput
Or, for older versions of Django:
python manage.py syncdb --noinput
Run testing server:
python manage.py runserver
Take a look at http://localhost:8000 . You can log in to
administration with username admin and password admin.
I followed all their instructions when I run.
python manage.py migrate --run-syncdb --noinput
I get the following
Operations to perform:
Synchronize unmigrated apps: embed_video, example_project, messages, posts
Apply all migrations: admin, auth, contenttypes, sessions, sites
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Running migrations:
No migrations to apply.
When I run
python manage.py runserver 8080
I get the following
Performing system checks...
System check identified no issues (0 silenced).
February 13, 2019 - 15:52:08
Django version 1.11.20, using settings 'example_project.settings'
Starting development server at http://127.0.0.1:8080/
Quit the server with CTRL-BREAK.
When I go to http://127.0.0.1:8080/ I see the following
What am I doing wrong here?
I recently added a model to my app (UserProfile) and when I pushed the changes to Heroku, I think I accidentally ran heroku run python manage.py makemigrations. Now when I try to run heroku run python manage.py migrate I get the error below
(leaguemaster) benjamins-mbp-2:leaguemaster Ben$ heroku run python manage.py migrate
Running `python manage.py migrate` attached to terminal... up, run.1357
Operations to perform:
Synchronize unmigrated apps: allauth
Apply all migrations: auth, admin, socialaccount, sites, accounts, account, contenttypes, sessions, leagueapp
Synchronizing apps without migrations:
Creating tables...
Installing custom SQL...
Installing indexes...
Running migrations:
No migrations to apply.
Your models have changes that are not yet reflected in a migration, and so won't be applied.
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
How do I fix this? Please help!
You need to first create the migrations locally, add them to your repository, commit the files with the new migrations and then push to heroku.
The sequence is something like this:
1. (add/modify some someapp/models.py)
2. python manage.py makemigrations someapp
3. python manage.py migrate
4. git add someapp/migrations/*.py (to add the new migration file)
5. git commit -m "added migration for app someapp"
6. git push heroku
7. heroku run python manage.py migrate
1. Make migrations locally
$ python manage.py makemigrations && python manage.py migrate
2. Commit changes and push it on the server
$ git add --all
$ git commit -m "Fixed migrate error"
$ git push heroku master
3. Now run migrate on the server
$ heroku run python manage.py migrate
You also need to be sure that you haven't ignored these migration paths in your .gitingnore file
It sounds like you ran makemigrations after you made changes to your model but before you had an initial migration file. Try to revert your app to the state it was before you added the new model and run makemigrations again to create the initial migration. Then add your updates back in and run makemigrations once more. This will create a second migration from your initial data structure to the new updated one. Then try your deployment.
https://docs.djangoproject.com/en/1.7/topics/migrations/#adding-migrations-to-apps
Answered for my case:
your_field=models.CharField(max_length=9,default=False)
Convert to
your_field=models.CharField(max_length=9,default='False')
My case:
In models.py for the field I wanted to set the default value to False. First default = False my contract without ''. But after running python manage.py migrate, I got the above error. The problem was solved after placing False inside ''.
Sometimes it is necessary for the default value in our field model to be a False string type.
If
default = False
If you write in the model, you will encounter this error.
In fact, depending on the type of field we have, we can not always set the default value of a field in the model to True or False. Must be converted to string for CharField type.
I've installed South on my existing Django app. This Django app is on Heroku as well.
Without making any changes to the models, I've done the following commands locally:
manage.py schemamigration app_name --initial
manage.py migrate --fake
Then I attempted to push heroku master, and migrate there. But I receive the following:
Running migrations for app_name:
- Nothing to migrate.
- Loading initial data for notecards.
No fixtures found
I get the same message if I try to fake the Heroku migrate.
I figured, this may be ok since technically there is nothing to migrate as the db stays the same.
So I made a small change to one of the models and did the following:
manage.py schemamigration app_name --auto
manage.py migrate
I then pushed to Heroku and attempted to migrate there, and I still receive the following:
Running migrations for app_name:
- Nothing to migrate.
- Loading initial data for notecards.
No fixtures found
Any help with what I'm doing wrong would be great. THanks.
For anyone else who comes across this issue, and for my own reference. Thanks to Chris Pratt for putting me on the right track.
This was resolved by:
Locally:
recursively removing any old migrations git rm -r migrations
flushing old database (this removes all data, but for me this wasnt an issue) manage.py flush
delete migrations folder in app folder
run initial schemamigration manage.py schemamigration --initial
run fake migrate manage.py migrate --fake
push heroku master
On Heroku:
migrate heroku run python manage.py migrate app_name
Then, locally, you can run migrate --auto, push to heroku, and run migrate app_name