This is a web-based application created using Django framework that allows users to view and vote in polls.
- Users can view the list of polls.
- Users can vote in each poll.
- Users can view the results of each poll.
- The application has an admin panel that allows managing (create, update, delete) the polls.
- Python 3
- Django Framework
- MySQL Database
Before you start, make sure you have Python and pip installed on your machine.
-
clone the repository to your local machine:
git clone https://github.com/yourusername/yourrepository.git
-
Navigate to the project directory:
cd django_polls_app
-
Install the required modules:
pip install -r requirements.txt
To start the application navigate to the project directory and run: python manage.py runserver
This will start the server at http://127.0.0.1:8000/.
Navigate to http://127.0.0.1:8000/polls to use the application.
-
This project uses pip to manage Python dependencies.
-
Navigate to the base directory of the project, the same location as the
requirements.txt
file. -
Run
pip install -r requirements.txt
to install all Python dependencies.The
requirements.txt
file includesmysqlclient
, which is the MySQL client library that Django uses to interact with the MySQL database. It was installed with the commandpip install mysqlclient
.Note:
<version>
should be replaced with the version ofmysqlclient
you're using. If you're unsure, runningpip show mysqlclient
in your terminal will display information about your installedmysqlclient
package, including the version.
This project uses python-dotenv to load environment variables from a .env file. In order to run this project locally, you'll need to create your own .env file in the root directory of the project and define the following variables:
Copy code
DJANGO_SECRET_KEY=<your Django secret key>
DB_NAME=<your database name>
DB_USER=<your database user>
DB_PASSWORD=<your database password>
DB_HOST=<your database host>
DB_PORT=<your database port>
Please replace the placeholders with your actual values.
Do not include your .env file in any version control system. It contains sensitive data that should not be shared. If you're using git, the .env file is already included in the .gitignore file and will not be tracked.
The use of environment variables and .env files is a common practice to manage project settings. It provides a few benefits:
Security: It prevents sensitive data from being shared publicly. Flexibility: It allows each developer to have their own settings. This is particularly useful when working in a team where each developer might have their own database setup. Organization: It helps keep configuration values separate from the codebase, which is a best practice in software development.
Enjoy the app!