Issue
I just installed virtualenv and in it I installed django. However, when I go to the django-admin terminal in the bin file, I wrote
django-admin startproject mysite
I thought that would start a new project but it just returned
Note that only Django core commands are listed as settings are not properly configured (error: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.).
Solution
Here is how to start a new django project in a virtualenv:
1. Create a new virtualenv for your project:
virtualenv py_env --python=python3
--python=python3
is not mandatory. I'd recommend programming in python3.x but this is up to you. If you are unsure about what is the default python that will be used when omitting the --python
option, type python -V
in your terminal.
2. Activate the virtualenv:
source py_env/bin/activate
If you see a (py_env)
at the beginning of the command line, then you know the virtualenv is activated. To deactivate, simply type deactivate
.
3. Install the required packages:
pip install django
While this is not needed, I recommend using ipython, so you might want to run pip install ipython
.
4. Create a new django project:
django-admin startproject mysite
Hope that helped and happy coding!
Answered By - jojo Answer Checked By - Terry (WPSolving Volunteer)