A comprehensive Poll and Survey application built using Django and Django REST Framework (DRF). This project enables users to create, manage, and participate in polls/surveys with real-time analytics for poll results.
- User authentication and registration using JWT
- Create and manage polls and survey questions
- Submit answers to polls
- Real-time poll result visualization (chart-based)
- Permissions to restrict multiple submissions by the same user
- Full API documentation (Postman)
- Django - Web framework for building the backend
- Django REST Framework (DRF) - For creating APIs
- JWT - For user authentication
- Matplotlib - For generating chart-based analytics for poll results
- SQLite - Database for development
Ensure you have the following installed:
- Python 3.x
- Django 4.x or higher
- Django REST Framework
- Matplotlib for charts
- JWT (JSON Web Token) for authentication
-
Clone the repository
git clone https://github.com/Mann10/poll_survey_project.git cd poll_survey_project -
Create and activate a virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Run migrations
Before you run migrate command make sure you do below changes. Configure settings.py: Open poll_survey_project/settings.py and make the following changes: SECRET_KEY = b'whateveryoulike' DEBUG = True ALLOWED_HOSTS = [] Comment out the following lines if they exist: database_url = os.environ.get("DATABASES_URL") DATABASES['default'] = dj_database_url.parse(database_url) python manage.py migrate
-
Create a superuser
python manage.py createsuperuser
-
Run the development server
python manage.py runserver
-
Access the app
- The API will be available at
http://127.0.0.1:8000/ - Admin dashboard at
http://127.0.0.1:8000/admin
- The API will be available at
The API documentation is available via Postman and can be accessed using this link:
Here are some of the key API endpoints:
-
User Registration
POST /api/users/register/
Registers a new user. -
Login
POST /api/users/login/
Logs in a user and returns a JWT token. -
Polls
GET /api/polls/
Lists all polls.
POST /api/polls/
Creates a new poll (Admin only). -
Poll Detail
GET /api/polls/{poll_id}/
Retrieves details of a specific poll. -
Submit Poll Answer
POST /api/polls/{poll_id}/submit/
Submits answers to a poll. -
Poll Results (Chart-based)
GET /api/polls/{poll_id}/results/
Displays poll results with charts.
- Only authenticated users can submit answers to polls.
- A user can submit answers to a poll only once (based on custom permissions).
- Admin users can create and manage polls.
To authenticate with JWT, use the Authorization header with the token:
Authorization: Bearer <your-token>Real-time chart-based analytics for poll results are generated using Matplotlib. Once users submit their answers, results are visualized in bar charts.
- Fork the repository
- Create your feature branch (
git checkout -b feature/new-feature) - Commit your changes (
git commit -m 'Add some feature') - Push to the branch (
git push origin feature/new-feature) - Open a pull request
This project is licensed under the MIT License - see the LICENSE file for details.