Location of manage.py file for django-disqus - django

Everything on the install of django-disqus has gone smooth till now.
I ran manage.py as instructed to here: http://django-disqus.readthedocs.org/en/latest/commands.html but the output was all wrong because I ran the dumpdata command on the wrong manage.py file.
./manage.py dumpdata
Where is the manage.py file I'm to run dumpdata on?
I'm attempting to setup the dump as a .json so that the comments are pulled locally as seen here: http://docs.disqus.com/help/58 It keeps a backup and is good for seo.

The docs you linked are to custom management commands that django disqus adds...
You use the project's ./manage.py, but now it has added functionality by typing:
./manage.py disqus_dumpdata

Related

Django data was not brought to heroku

I have Django apps, which include users and posts models. The apps work perfectly at local following making migrations and migrating. I tried two different ways to deploy the apps to Heroku. First, using Heroku Git, the apps works on Heroku the same as at local.
When using GitHub, however, all data were not brought to Heroku. I tried to run "python manage.py makemigrations" and "python manage.py migrate" on Heroku, but the data from local was not brought still.
I would really appreciate it if you could please explain and help with the issue using GitHub.
I think you have to migrate on Heroku as well, try:
heroku run python manage.py migrate
See the heroku docs
check your .gitignore file maybe db.sqlite in gitignore file and you can remove it
another option is dumpdata and load in production
you can run
python3 manage.py dumpdata > data.json
and load data in production
python3 manage.py loaddata data.json

Django on Heroku - ProgrammingError at / relation "..." does not exist

I'm getting this error. I know you usually get this error because the databases wasn't properly migrated.
When I run heroku local web, the website works fine when I go to localhost:5000.
However after I deploy the app to heroku with git push heroku master, the error comes up.
In other words, it works in my local environment. But it does not work after deploying to heroku.
I have Heroku-Postgres installed as an add-on in heroku.
What could be causing this?
excute migrations and makemigrations in bash heroku. open the terminal in the local project folder and give the following commands:
heroku run bash
~$ ./manage.py makemigrations
~$ ./manage.py migrate
~$ exit
The following steps did it for me
Make all the necessary migrations (python manage.py makemigrations) and migrate (python manage.py migrate) locally,
push to heroku master
and finally running heroku run python manage.py migrate
Solved the issue
I experienced the same error after making a change to a model and then deploying this change to heroku.
The only way I managed to fix this problem was to do the following:
Reset the database in heroku
Delete the migrations files from the migrations folder for the broken app locally (but keep the directory and the __init__.py file)
Run python manage.py makemigrations and python manage.py migrate. This will repopulate the migrations folder with clean migration files.
Push changes to master (ensure that you do not have migrations directories in .gitignore files.
Deploy changes to heroku
Run the heroku shell heroku run bash
Run python manage.py migrate
I was able to do this because my tables did not have much data in, but I would try to avoid resetting the database if I had more data in my tables.

run manage.py where manage.py is not present?

manage.py is under project_home/mysite/mysite/bin/manage.py
I did it following a recommendation from some book.
The point is it's rather hard to execute python manage.py something as it stands since I have to move to the directory or type the directory path leading to it.
Is there a convenient way to call manage.py in this setup?
If you want to call manage.py anywhere, you can use Django-manage.py-anywhere. As package description says you can run manage.py commands from any directory of your Django project.
See more here: https://github.com/timonweb/Django-manage.py-anywhere

problems updating DB to heroku with south migrations

I have a Django proyect running in heroku for some time now, the thing is that, tree days ago, I've tryed to update my schema model but, every time I write
heroku run python manage.py migrate quizzer
heroku keeps telling me that everything's up to date, but I've changed my models.py folder and run schema migration as always.
If you know why this is happening or how can I force a schema migration to my heroku app please tell me how.
Ps: I cannot delete the hole database as the data stored in heroku and the data stored in my local server database are not the same, and I don't want to loose the data of my users
Here is a workflow for running a schemamigration on quizzer after modifying your models.py
./manage.py schemamigration quizzer --auto # create migration
./manage.py migrate quizzer # apply migration locally
git add .
git commit -m "Changed quizzer models, added schemamigration"
git push heroku
heroku run python manage.py migrate quizzer # apply migration on heroku
It sounds like you might have forgotten to check your migration file (usually found in appname/migrations) into git, commit it and push it to heroku.
I had this problem too. I solved this by running heroku restart and running the migrate command again. Don't know why it works (suspect it has to do with initial), but at least it works.
Hope that helps!
South might be missing from requirements.txt. Try:
pip freeze > requirements.txt
...followed by another git add/commit/push.
Also, according to the South installation instructions, syncdb must be run first, "to make the South migration-tracking tables". So try:
heroku run python manage.py syncdb
...then try the migrate command again.

DatabaseError: no such column error

So I have a model that I wanted to add ImageField to, so I typed in
picture = models.ImageField(upload_to='media/images')
I then ran syncdb and went into the shell:
python2 manage.py syncdb
python2 manage.py shell
I then imported the model and tried
"model".objects.get(pk=1)
I get the error:
DatabaseError: no such column: people_people.picture
When I run manage.py sql for the model
"picture" varchar(100) NOT NULL
is in the database.
What solutions do you guys have? I can't delete the data in the database.
As noted in the documentation syncdb doesn't add columns to existing tables, it only creates new tables.
I suggest running
python manage.py sqlall <your_app>
Looking at the sql it outputs for the table you're changing, and then running
python manage.py dbshell
in order to manually issue an ALTER TABLE command.
In future, you might like to use a migration tool like South.
There are two possibilities that to get this error 1) You added extra field to model after doing the syncdb. 2) you added new class to model.py file in django.
Solution for this is:
First install south by using command
for windows: **easy_install south** //for that you need to go to the script folder of python folder in c drive.
for linux: **sudo easy_install south**
Then follow the steps which are included here migration tutorials
step1- python manage.py schemamigration your_app_name --initial
step-2 python manage.py migrate your_app_name
Hope this will help you.
As of 1.7 migrations within Django replaces South.
Create a new set of migration instructions by running the following command in terminal:
$ python manage.py makemigrations
Check the output in the migration folder it creates to make sure they make sense then run the following terminal command to complete the migrations:
$ python manage.py migrate
That's it.
Running migrations this way allows others to implement the same migrations instead of having to manually implement db changes on every machine using the code. On the new machine all they have to run is:
$ python manage.py migrate