Django only runs by command line but not in PyCharm - python

I'm trying to run a Django (version 2.1) project in PyCharm, and the run configurations are properly set to work with the right environment and to use the manage.py file to run the server. At least with other projects in PyCharm I can run without problems. But why I only get the following error
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured
only when running directly from PyCharm? By command line it runs perfectly fine with the command 'python manage.py runserver'.

Related

How to solve Local path <path> is not registered within uploads in the request in PyCharm 2022.2.1 (Professional Edition)?

I want to set up a Django project with docker-compose and PyCharm on my PC with Ubuntu 22.04 OS. Using PyCharm 2022.2.1 (Professional) I get the following error
How to solve Local path is not registered within uploads in the request
I added a Python interpreter from Settings > project > Python interpreter and then add interpreter > on SSH after that entered ssh credentials and on the system interpreter finally I created the Python interpreter.
I have docker-compose run on another terminal.
After I run the runserver command it shows this error:
this is the runserver command configuration:
I have recreated the interpreter, and explored the same problems on JetBrains website but couldn't solve the issue.
This bug was reported as PY-55396 on the JetBrains bug tracker.
The bug was solved in PyCharm 2022.2.2, the solution is to upgrade to that version or downgrade to PyCharm 2021.3.

Django manage.py migrate command cannot access Linux environment variables

Python cannot access environment variables while running any command. For example, after running
python3 manage.py migrate
an error occurs:
django.db.utils.OperationalError: (2006, "Access denied for user 'dbmasteruser'#'0.0.0.0' (using password: YES)")
But if I insert a plain string value for database password instead of os.environ.get('PASSWORD'), command works fine.
All environment variables are written in setenv.sh file, but I have also tried to set them alternatively using command export PASSWORD=password.
Executing command using sudo doesn't work either.
However, Apache deployment server can read those environment variables without any issues, but the problem occurs while running migrations or any other command. How can I solve it?

'django' is not recognized as an internal or external command,

I have been using django commands in my virtual environment for a longtime....
suddenly today
When i run this command in my cmd from my Anaconda Env.....
django manage.py runserver
cmd responded with this
'django' is not recognized as an internal or external command,
operable program or batch file.
when i ran the command "conda list" it shows django package in the list...
do anyone know a solution to this??
You should run it with python
python manage.py runserver
And make sure you have Django installed properly, and keep in mind you won't use anaconda for Django. Plus, if you're starting a project, the proper command will be
django-admin startproject project_name
Call Django with django-admin. Not exactly intuitive, but this is how Django works.

PyCharm Run Issues Django With External Virtual Environment

I'm using Pycharm 2016.3.2 on Windows 10. I have a Django project using an separate virtual environment( ie. virtual environment is in totally separate folder to the project). I am using a Postgres server which is working fine and can be seen by Pycharm and can test connect. The problem I have is when I go to Run it in Pycharm the server is not starting. I get the following in the Run window:
"C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\bin\runnerw.exe" C:\Pyprojects\VirtualEnvs\venv2\Scripts\python.exe C:/Pyprojects/MyProject/manage.py runserver 8000
Process finished with exit code -1073741819 (0xC0000005)
I can attest to this all actually working outside Pycharm. I can use 'runserver' from my virtual environment using Windows command prompt. I can then get into my django site once I've started it that way with no problems.
Can anyone shed some light on how to make this work with Pycharm? I just purchased Pycharm professional and hopefully this will have some kind of easy fix.
Thanks in advance for any help.
Marco

Django manage.py error when run from a shell script

When I type and execute the command python manage.py runserver localhost:8080 directly in the terminal everything works fine but when I place the command inside a shell script I get the following error:
The script contains the following:
Does anyone know why this is happening?
There are spaces in the script after runserver.
You should remove these to ensure you're only running the desired command without any indication of host / port.

Categories

Resources