This guide will walk you through the process of cloning a Django project from GitHub, setting up a virtual environment, installing dependencies, and running the project on your local machine. The instructions are provided for both Windows and macOS.
Before you begin, make sure you have the following installed:
- Python (3.8 or higher)
- pip (Python package manager)
- Git
First, clone the repository from GitHub to your local machine. Open your terminal (Command Prompt for Windows, Terminal for macOS) and run the following command:
git clone https://github.com/your-username/your-project-name.gitReplace https://github.com/your-username/your-project-name.git with the URL of your GitHub repository.
Navigate to the project directory:
- شغل المشروع من ال visual studio وافتح ال terminal
cd your-project-nameCreate a virtual environment by running:
python -m venv venvActivate the virtual environment:
.\venv\Scripts\activateCreate a virtual environment by running:
python3 -m venv venvActivate the virtual environment:
source venv/bin/activateWith the virtual environment activated, install the project dependencies by running:
pip install -r requirements.txtThis command installs all the packages listed in the requirements.txt file, which is typically included in the root of your Django project repository.
Before running the server, you may need to apply migrations and create a superuser to access the admin panel (optional but recommended).
Apply migrations:
python manage.py migrateCreate a superuser:
python manage.py createsuperuserFollow the prompts to create a superuser account.
Finally, start the Django development server:
python manage.py runserverThis command starts a local web server running on http://127.0.0.1:8000/.
You can now open a web browser and visit http://127.0.0.1:8000/ to see the project running locally.
