Error in makemigrations and migrate in pycharm using django - django

Guy i was working on a django website i create a django website before also but this time when ever i run command
Python manage.py makemigrations
Its stop there no error nothing shows after this command
Suggest me what to do
And one thing i run the python makemigration blog
(Blog is app name here)
Its is working properly then but after this migrate command will hang
Detail : I created a project name blogs
And inside it i create a app blog
I am using postgresql database
After writing model class
I run the make migration command
And it shows nothing and no other command i can write after this as shown in image enter image description here

virtual environment using pipenv (follow below commands)
pipenv install django==3.0.1
then start the virtual enviorment
pipenv shell
then run your migrations command

Related

ImportError when using heroku for my django web

I checked django is installed properly and in my 'requirements.txt' I wrote 'Django==3.2.3'. However, I cannot use this code:
heroku run python manage.py migrate
So I checked this code:
python manage.py migrate
and found out it worked properly. I know that there are existing questions and read many of them, but I think I have tried everything I could do. I would be really grateful if someone can solve this problem.
your question isn't clear tbh.
install all the dependencies by using the pip freeze command and try to run your heroku commands in the heroku bash available in your heroku dashboard
to run the commands on your heroku machine from your CMD, then command is
heroku run bash --app your_app_name
then you can run whatever command you want.
but I am not sure what is the exact problem you are having.

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.

PTVS Django Data Base Migration

Im testing Python Tools For Visual Studio, I create a django project, make a SyncDB and install django admin with no problems, but now Im trying to make Data Base migration like: Django 1.7 Migrations. the point is that i cant figuer out how to do that. I serched in google and find this: How to run django database migrations with PTVS?. So the migration command is not wraped. I tried using Windows Command Prompt and install C:\Python34\;C:\Python34\Scripts; PATHS but when i type a django command like python manage.py runserver appears No module named 'django'. It seems that i am not pointing to my django project virtual env, but i dont know how to do that.
Execute command in my django app env path does not work neither.
Image:
Thanks a lot!
Before using of virtual env you should activate it. Execute env\activate or env\bin\activate. Not a windows guy so I'm not sure which path virtualenv uses on Windows :-)
You have to activate virtualenv. Go to env/Scripts directory and run activate.bat. Then go to your main project directory and try again python manage.py runserver. If you still see No module named 'django' make sure that django is installed in this environment try pip install django.

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

Location of manage.py file for django-disqus

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