Django: python manage.py migrate does nothing at all - python

I just started learning django, and as i try to apply my migrations the first problem occurs. I start the server up, type
python manage.py migrate
and nothing happens. No error, no crash, just no response.
Performing system checks...
System check identified no issues (0 silenced).
You have 13 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
May 01, 2017 - 11:36:27
Django version 1.11, using settings 'website.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
python manage.py migrate
And that's the end of my terminal feed.
I thought maybe it just looks like nothing happens, but no. The changes weren't applied and I can't proceed any further. Any ideas on what's going on?

Well, you say that you first start the server and then type in the commands. That's also what the terminal feed you shared shows.
Do not run the server if you want to run management commands using manage.py.
Hit Ctrl+C to exit the server and then run your migration commands, it will work.

Try:
python manage.py makemigrations
python manage.py migrate

#adam-karolczak n all
If there are multiple DJANGO Projects, it can happen that DJANGO_SETTINGS_MODULE is set to some other app in environment varibles, the current project manage.py will not point to current project settings thus the error.
So, confirm DJANGO_SETTINGS_MODULE in fact points to the settings.py of current project.
Close the project if its running viz. ctrl+C.
You can also check the server is not running ( linux ) by
ps -ef | grep runserver
Then kill the process ids if they exist.
If you confirmed settings.py in DJANGO_MODULE_SETTINGS is for the project you are having issue.
Run the following it should resolve.
python manage.py makemigrations
python manage.py migrate
Hope it helps.

I was getting the same error
running this 2 command in terminal
python manage.py makemigrations
python manage.py migrate
and then
python manage.py runserver
solved my issues.
Thanks

Have you tried with parameter?
python manage.py makemigrations <app_name>

I had the same issue and the problem was that there was a pg_dump script running at the same time I was trying to migrate. After the dump was completed, migrations ran successfully.

Check that INSTALL_APPS app exists, if not add it
Checks the model for default attributes
Running this 2 command in terminal
python manage.py makemigrations
python manage.py migration

First exit of the present web server by typing Ctrl + C
Then run python manage.py migrate
The Warning is due to not configuring the initial database or migrating.

Related

How to run Django project in background

Recent I am running Django project on terminal using this command:
python manage.py runserver 0.0.0.0:80
But Server is stopped by closing terminal, So I need to run server in background.
How can I solve this issue?
You can use the nohup command, so your command runs without the terminal and all the outputs from the program will go to the file nohup.out (in the same directory you ran the command).
Use like so:
nohup python manage.py runserver 0.0.0.0:80
You can use screen to run a program in background.
This should answer your question
You may try:
python manage.py runserver 0.0.0.0:80 &
"&" puts the executed command in background and sets init as it's parent process when you close the terminal
You can run nohup, an output of the command will not be set what will not be created in the command (where or was executed)
nohup python manage.py runserver 0.0.0.0:8000
If you are using some automation software, in order not to crash the deployment, add an '&' at the end of the command, like this
nohup python manage.py runserver 0.0.0.0:8000 &

How to create superuser in django using Unix Environment

when I'm using Visual Studio Code for the Django project in windows Environment, for creating a superuser I'm using the below command.
(test) C:\Users\SAHEB\projects\project>python manage.py createsuperuser
this same Django project is deployed in Unix server, below is the path where whole project is deployed.
/apps/sample/python
but python manage.py createsuperuser this command is not working in Unix server from this path, what's the solution
from_the_docs: runserver is to start a server and not to create superuser.
from_the_docs: To create superuser run following command:
django-admin createsuperuser
python manage.py createsuperuser works on all platforms. I think it's because of your path. Type dir and press enter in your cmd (make sure you do it in your project directory) at let's see if there is a file called manage.py or not.
(test) C:\Users\SAHEB\projects\project>dir

django runserver gets killed

When there are simultaneous ajax request sent to runserver its gets killed.
I know earlier it was single threaded, but --nothreading option says it is now multithreaded by default. Still, my runserver gets killed.
I am running on django==1.10 and python==2.7
How do I stop runsever from getting killed?
Or This is because of python's multithreading limitations?
Out of trial and error, I found the way to stop runserver from getting killed.
--nothreading actually solved my problem automagically.
so final commands to run dev server is.
django-admin runserver 1.2.3.4:8000 --nothreading
or
python manage runserver 1.2.3.4:8000 --nothreading
Happy I am :-)

Manage.py runserver for demonstration

How would I run a Django application on, a digitalocean droplet let's say, with just using the development server Django provides. I've tried just running python3 manage.py runserver, but I can't pull it up with the browser from another computer
I know this is bad practice, but I really only need it up to demonstrate for a class project
by default runserver only listn on 127.0.0.1 that is not accessible from remote computer.
run
python3 manage.py runserver 0.0.0.0:8000
will solve it, simply check the real IP if the machine and use it as address in your browser
python3 manage.py runserver <your IP address>:8000

manage.py flag to force unattended command?

I am reading this tutorial: Installing and Configuring Graphite and Statsd on an Ubuntu 12.04 VPS
and I am working to automatize everything is possible then there is one step of this tutorial that is giving me crazy:
Next, we will configure the Graphite database. Go to the Graphite
webapp directory and run the database script:
cd /opt/graphite/webapp/graphite/
sudo python manage.py syncdb
As you see, we have to run the manage.py and when I run syncdb ask about a creation of superuser. How can I avoid that? I would like to run these sending all parameters to make an automatic script.
Any ideas?
You can use the --noinput argument to disable those prompts for the syncdb command.
--noinput
Use the --noinput option to suppress all user prompting, such as “Are you sure?” confirmation messages. This is useful if django-admin.py is being executed as an unattended, automated script.

Categories

Resources