Apart from a dockerized solution discussed by Robert, the simplest way to get started is to create a virtual environment on your local machine to install the packages needed by your Django application. Here are the steps that I follow whenever I need to work on a new project.
Step 1: Virtual Environment
I have created a venv directory in my home directory and I create virtual environments there. I create a new virtual environment for each of my projects to keep things separated and clean.
virtualenv -p python3 ~/venv/newproject
Step 2: Create a Project
Navigate to the directory where you want to create your project and then execute this command:
django-admin startproject newproject
Step 3: Activate Virtual Environment
Activate the virtual environment, and install Django in your virtual environment.
That's it. Now you should install all the requirements of your project keeping the virtual environment activated and thus you will be able to freeze your requirements to requirements.txt cleanly. Moreover, you will be able to keep the rest of your main Python environment clean on your local machine.
I hope this helps. This is what I follow as a practice while building Django projects. And when it comes to deploying the project to the server, I freeze the project's requirements to a requirements.txt file from the virtual environment that I created just for that project.
You can create the virtual environment before creating your project or after creating the project. To create the project, you use django-admin command and I assume that django-admin command is available globally on your machine. Once the project is created, you should create a virtual environment for it and then you should install all the requirements of the project in that virtual environment (including the main Django package).
So the virtual environment's role here is just to allow you a dedicated place to install your project's requirements. This way, you don't mess your system with the packages required by a certain project.
p.s. if django-admin command is not available globally in your terminal, first create the virtual, activate it, install Django package, and then create your project.
Install docker and run django and the db inside docker containers. Use docker compose for composition.
There are bunch of examples of dockerized environments for Django project at GitHub and so on. Just google for it.
Have fun hope it helps.
Data-scientist who loves to use #datascienceforgood, especially in ecology, energy and the environment. Bonsai, gardening, bikes and music when I'm not at a keyboard.
I believe you have already activated your virtual environment and then you have installed django in it. If not then activate it then run the following command
pip install django
Apart from a dockerized solution discussed by Robert, the simplest way to get started is to create a virtual environment on your local machine to install the packages needed by your Django application. Here are the steps that I follow whenever I need to work on a new project.
Step 1: Virtual Environment
I have created a
venv
directory in my home directory and I create virtual environments there. I create a new virtual environment for each of my projects to keep things separated and clean.Step 2: Create a Project
Navigate to the directory where you want to create your project and then execute this command:
Step 3: Activate Virtual Environment
Activate the virtual environment, and install Django in your virtual environment.
That's it. Now you should install all the requirements of your project keeping the virtual environment activated and thus you will be able to freeze your requirements to requirements.txt cleanly. Moreover, you will be able to keep the rest of your main Python environment clean on your local machine.
I hope this helps. This is what I follow as a practice while building Django projects. And when it comes to deploying the project to the server, I freeze the project's requirements to a requirements.txt file from the virtual environment that I created just for that project.
thank you!!
this is what I've figured out so far.... is this good as well?:
just by entering/running....
1) python3 -m venv customname-env
2) source customname-env/bin/activate
3) python -m pip install Django
Yep, this is exactly what I've mentioned above. You are on the right track :)
but, I need a ENV first?
You can create the virtual environment before creating your project or after creating the project. To create the project, you use
django-admin
command and I assume thatdjango-admin
command is available globally on your machine. Once the project is created, you should create a virtual environment for it and then you should install all the requirements of the project in that virtual environment (including the main Django package).So the virtual environment's role here is just to allow you a dedicated place to install your project's requirements. This way, you don't mess your system with the packages required by a certain project.
p.s. if
django-admin
command is not available globally in your terminal, first create the virtual, activate it, install Django package, and then create your project.Install docker and run django and the db inside docker containers. Use docker compose for composition.
There are bunch of examples of dockerized environments for Django project at GitHub and so on. Just google for it.
Have fun hope it helps.
I'd recommend having a look at @williams.vincent here, and his books on Django. I think they're great.
django-admin startproject
Then you are good to go
What about.....
python -m pip install Django?
To create a env run this command
virtualenv
I believe you have already activated your virtual environment and then you have installed django in it. If not then activate it then run the following command
pip install django
I want to use the environment