Hey I am trying to replace storing files to using cloudinary in my django app. I add
image2 = CloudinaryField('image')
to my models.py and run make migrations but nothing happens. Then when I run the server I get the error that image2 column does not exist. anyonee know what is gong on?
The following steps should work for you:
Adding image2 = CloudinaryField('image') to your models.py file
./manage.py makemigrations myapp
./manage.py migrate myapp
Make sure you run the migrate instruction as well
`
Related
First I create a new app book and create a model class book, then I messed up with that. I delete that app and create another app and run python3 manage.py runserver.
Then I get this error:
.
I don't add anything in the new app. What can I do now? Is there anything more I want to specify?
project directory and installed apps
enter image description here
after creating any app in django, you need to add it's name to the INSTALLED_APPS inside the settings.py file.
Also make sure to run makemigrations before running migrate command like below:
python manage.py makemigrations
for a specific app:
python manage.py makemigrations <app name>
I just added a many-to-many relationship to my model and generated the new migration file:
py manage.py schemamigration myapp --auto
Then tried running the migration:
py manage.py migrate myapp
It did not complete successfully, raising a south.exceptions.NoMigrations exception:
south.exceptions.NoMigrations: Application '<module 'djcelery' from 'C:\Python27\lib\site-packages\djcelery\__init__.pyc'>' has no migrations.
No more information is given, and I cannot figure out what might be wrong. Has anybody experienced this issue before?
I am using Python 2.7 and Django 1.4.22.
I am trying to upgrade from Django 1.6.7 to Django 1.7.1, so I have been trying to migrate my app.
I have followed the django docs here.
I deleted the south from my installed apps.
In the migration directory, I delete the numbered migration files and the .pyc files but I kept the directory & __ init__.py file.
I then run :
python manage.py makemigrations your_app_name
I receive the following confirmation message:
Migrations for 'your_app_name':
0001_initial.py:
- Create model UserProfile
Next I run:
python manage.py migrate your_app_name
I received the following error:
CommandError: App 'your_app_name' does not have migrations (you cannot selectively sync unmigrated apps)
As per the docs, I also ran:
python manage.py migrate --fake your_app_name
I received the same error message:
CommandError: App 'your_app_name' does not have migrations (you cannot selectively sync unmigrated apps)
Can anyone shed some light on why this will not work for me?
I noticed that only those apps that actually contain a migrations folder that contain a file __init__.py are recognized by migrations. IE having only models.py in your app is not enough.
If you have a single app, running migrate without specifying the app or migration may work.
If so, the first thing to check is that your app name matched that specified in your settings.py under INSTALLED_APPS.
As pointed out in the comments, app names can be in the form [parent_app].[app_name]. In this case, migrate needs [app_name] only.
Your app must contain a models.py file (even emtpy).
Source: https://groups.google.com/forum/#!msg/django-users/bsTZEmxgDJM/wH0p3xinBWIJ
Just to mention another possible reason:
In my Django app i added the correct migrations and installed the app with pip and got the same error.
What i was missing is a correct MANIFEST.in file
Also the parameter include_package_data in setup() from the setup.py file was not set to True.
I am trying to migrate a model that has nothing to do with this and as soon as I do migrate it gives me this error:
NoMigrations: Application '<module 'django.contrib.comments' from C:\Python27\lib\site-packages\django\contrib\comments\__init__.pyc' has no migrations.
I have tried deleting migrations folder and deleting databases but keeps coming up.
It can be that you have another app named as the last part of the module in this case 'comments' or you have an entry in the database table south_migrationhistory with app_name same as the module.
Found answer here Google Groups
i suggest if you can use django dumpdata , you will get a json file copy of your model.
$ python manage.py dumpdata <app-name> --indent=2
or create a folder to put the result in
$ python manage.py dumpdata <app-name> --indent=2 > [project]/[app]/[folder]/file-name.json
later you can use data upload to rebuild the original model.
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