Running migrations: No migrations to apply - python

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?

Related

' No migrations to apply' after Django migration

I made a new app called 'contact' which I added to installed_apps, but I can't create a table in the SQLite database!
Django version = 3.1
python manage.py makemigrations contact
No changes detected in app 'contact'
then for : python manage.py migrate contact
Operations to perform:
Apply all migrations: (none)
Running migrations:
No migrations to apply.
I have tried many solutions proposed by members here but None worked
like checking "init" file existed in migrations folder and it's empty or commands like these :
python manage.py migrate --fake contact zero
Operations to perform:
Unapply all migrations: contact
Running migrations:
No migrations to apply.
python manage.py migrate contact --fake-initial
Operations to perform:
Apply all migrations: (none)
Running migrations:
No migrations to apply.
This worked for me;
python manage.py makemigrations --empty yourappname
python manage.py migrate yourappname
It turns out adding an extra empty migration forces django to recheck the table and in the process, it noticed the new migrations. There's probably some caching taking place somewhere.
Original answer
Try not to use the name of your app.
Eg.
python manage.py makemigrations
python manage.py migrate
If don't work. You can do something more risky. Go to the directory of your project. Take the database to another folder. Make the same above commands.

Django: no migrations apply, but I have unapplied migrations

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

ValueError: Dependency on app with no migrations: account

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

Django 2.0 + Postgres heroku migrations

I am trying to run a Django application with Postgres in Heroku. I have created an app for the application but the problem is that the app migrations are not being applied in Heroku. I am using the heroku starter base template and have committed the necessary migration files.
When I run
heroku run python manage.py migrate, the first set of migrations apply:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
blah blah blah
But when I run it the second time it gives me the the output
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
No migrations to apply.
If I specify the app using
heroku run python manage.py migrate phone I get the error CommandError: No migrations present for: phone
In my local development, I have an app called phone that I have added to the settings.py and can run local migrations.

Django Heroku Error "Your models have changes that are not yet reflected in a migration"

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.

Categories

Resources