This project is a web application built using Django, a high-level Python web framework that encourages rapid development and clean, pragmatic design. This README provides instructions on setting up and configuring the Django environment.
Before you begin, ensure you have the following installed on your system:
- Python 3.6+
- pip (Python package installer)
- virtualenv (Optional but recommended for isolated environments)
-
Clone the repository:
git clone https://github.com/prath0m/First-Django-Project.git cd First-Django-Project
-
Create and activate a virtual environment:
It's recommended to use a virtual environment to isolate your project's dependencies.
python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required dependencies:
Install the dependencies listed in
requirements.txt
:pip install -r requirements.txt
-
Set up the database:
Django uses SQLite by default, but you can configure other databases like PostgreSQL or MySQL. Run the following commands to set up your database:
python manage.py migrate
-
Create a superuser:
To access the Django admin panel, you'll need to create a superuser account:
python manage.py createsuperuser
-
Run the development server:
Start the Django development server to see your application in action:
python manage.py runserver
Visit
http://127.0.0.1:8000/
in your web browser to view the application.
The settings.py
file in the myproject/
directory contains all the configuration options for your Django project, including:
- DEBUG: Set to
True
during development. Set toFalse
in production. - ALLOWED_HOSTS: Add your domain or IP address here when deploying to production.
- DATABASES: Configure your database engine and credentials here.
- STATIC_URL and MEDIA_URL: Define the URL paths for serving static and media files.
It's a good practice to store sensitive information like SECRET_KEY
, database credentials, and API keys in environment variables. You can use the python-decouple
package or similar tools to manage environment variables:
pip install python-decouple