{"id":14972606,"url":"https://github.com/hoangsonww/django-poll-application","last_synced_at":"2025-07-24T23:39:07.402Z","repository":{"id":243975853,"uuid":"813936639","full_name":"hoangsonww/Django-Poll-Application","owner":"hoangsonww","description":"🗳️ Welcome to the Django Polls App: Your interactive poll creation and voting platform! Craft custom polls, gather opinions, and visualize results with our user-friendly Django app. Experience the power of polls on the web right now! 🚀 ","archived":false,"fork":false,"pushed_at":"2025-01-15T20:02:40.000Z","size":826,"stargazers_count":18,"open_issues_count":0,"forks_count":12,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-01-16T23:42:40.323Z","etag":null,"topics":["backend","backend-api","django","django-application","django-framework","django-rest-framework","full-stack","fullstack-development","model-view-controller","mvc","mvc-architecture","poll-application","polling","rest-api"],"latest_commit_sha":null,"homepage":"https://hoangsonww.github.io/Django-Poll-Application/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hoangsonww.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-12T03:07:38.000Z","updated_at":"2025-01-01T04:28:06.000Z","dependencies_parsed_at":"2024-06-12T10:04:21.960Z","dependency_job_id":"cd8bf601-834a-4eca-ab28-15343db89644","html_url":"https://github.com/hoangsonww/Django-Poll-Application","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"02b266ab117512e83d49e03c626d3ee6f0e6bde9"},"previous_names":["hoangsonww/django-poll-application"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoangsonww%2FDjango-Poll-Application","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoangsonww%2FDjango-Poll-Application/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoangsonww%2FDjango-Poll-Application/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoangsonww%2FDjango-Poll-Application/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hoangsonww","download_url":"https://codeload.github.com/hoangsonww/Django-Poll-Application/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238394323,"owners_count":19464583,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","backend-api","django","django-application","django-framework","django-rest-framework","full-stack","fullstack-development","model-view-controller","mvc","mvc-architecture","poll-application","polling","rest-api"],"created_at":"2024-09-24T13:47:11.991Z","updated_at":"2025-02-12T00:31:49.630Z","avatar_url":"https://github.com/hoangsonww.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Django Poll Application\n\nThis repository hosts a simple, lightweight poll application that was built with Django, designed to showcase fundamental Django concepts like models, views, templates, and the admin interface.\n\n## Table of Contents\n- [Live Deployment](#live-deployment)\n- [User Interface](#user-interface)\n- [Features](#features)\n- [Technologies Used](#technologies-used)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Project Structure](#project-structure)\n- [Customization](#customization)\n- [Contributions](#contributions)\n- [License](#license)\n- [Contact](#contact)\n\n## Live Deployment\n\nYou can access the live deployment of this project [here](https://django-poll-application.onrender.com).\n\nThe app is hosted on Render, a cloud platform that offers free hosting for static sites and web services. The deployment is automatically updated whenever changes are pushed to the `master` branch.\n\nNote: The server may spin down after a period of inactivity, so the initial load time may be longer. It may take up to 2 minutes to load the page if the server is inactive for a while. Please be patient!\n\n## User Interface\n\n### Homepage\n\n\u003cp align=\"center\" style=\"cursor: pointer\"\u003e\n    \u003cimg src=\"readme-images/homepage.png\" alt=\"User Interface 1\" style=\"border-radius: 10px\" width=\"100%\"/\u003e\n\u003c/p\u003e\n\n### Poll Details\n\n\u003cp align=\"center\" style=\"cursor: pointer\"\u003e\n    \u003cimg src=\"readme-images/details.png\" alt=\"User Interface 2\" style=\"border-radius: 10px\" width=\"70%\"/\u003e\n\u003c/p\u003e\n\n### Poll Results\n\n\u003cp align=\"center\" style=\"cursor: pointer\"\u003e\n    \u003cimg src=\"readme-images/results.png\" alt=\"User Interface 3\" style=\"border-radius: 10px\" width=\"100%\"/\u003e\n\u003c/p\u003e\n\n### Admin Interface\n\n\u003cp align=\"center\" style=\"cursor: pointer\"\u003e\n    \u003cimg src=\"readme-images/admin.png\" alt=\"User Interface 4\" style=\"border-radius: 10px\" width=\"100%\"/\u003e\n\u003c/p\u003e\n\n## Features\n\n- **Create Polls:** Admin users can easily create questions and add multiple answer choices.\n- **Vote:**  Users can view available polls and vote for their preferred choices.\n- **Results:** Real-time results are displayed after voting, showing the distribution of votes.\n- **Admin Dashboard:**  A robust admin interface allows for managing questions, choices, and viewing results.\n- **Correct Answers:** Admin users can specify correct answers for each question, and users see if they voted correctly on the results page.\n- **Homepage and Navigation:** Clear navigation between the homepage (list of polls), poll details, and results.\n- **Basic Styling:**  Includes basic CSS styles for a clean and visually appealing presentation.\n\n## Technologies Used\n\n- **Django:** Web framework for rapid development.\n- **Python:** The programming language used for the backend logic.\n- **HTML/CSS:**  For structuring and styling the user interface.\n- **JavaScript (Optional):** Used for adding interactivity (e.g., Chart.js in your `results.html`).\n\n## Installation\n\n1. **Clone the Repository:** Clone the repository using the Code button in the repository's main GitHub page.\n\n2. **Create a Virtual Environment:**\n   ```bash\n   python -m venv .venv\n   ```\n\n3. **Activate the Virtual Environment:**\n   ```bash\n   source .venv/bin/activate  # Linux/macOS\n   .\\venv\\Scripts\\activate    # Windows\n   ```\n\n4. **Run Migrations:**\n   ```bash\n   python manage.py makemigrations\n   python manage.py migrate\n   ```\n\n5. **Create Admin User:**\n   ```bash\n   python manage.py createsuperuser\n   ```\n\n6. **Start the Server:**\n   ```bash\n   python manage.py runserver\n   ```\n   \n**Important**: Remember to change the Django production secret key and set `DEBUG` to `True` in `PollApplication/settings.py` order to run the server:\n```python\nSECRET_KEY = 'your_secret_key'\n\nDEBUG = True\n```\n\nAlso, as you develop the app, every time you make changes to the data in the back end, be sure that you migrate them to the SQLite database using the following commands:\n```bash\npython manage.py makemigrations\npython manage.py migrate\n```\n\nThen start the server again using `python manage.py runserver` and you'll be all set!\n\n## Usage\n\n1. **Access the Admin Interface:** Go to `http://127.0.0.1:8000/admin/` and log in with your superuser credentials.\n2. **Create Polls:**\n    - Click \"Polls\" or \"Questions\" in the admin interface.\n    - Click \"Add Question\" and fill out the question text and publication date.\n    - Click \"Save and continue editing\" to add answer choices.\n    - Mark the correct answer using the checkbox.\n3. **View Polls:** Visit the homepage (`http://127.0.0.1:8000/polls/`) to see the list of available polls.\n4. **Vote:** Click on a poll to view details and select your answer.\n5. **View Results:** After voting, you'll be redirected to the results page, where you can see the vote distribution and whether you answered correctly.\n\n## Project Structure\n\n- **`polls/`:**\n    - `models.py`: Defines the `Question` and `Choice` models.\n    - `views.py`: Contains the views for displaying polls, voting, and showing results.\n    - `admin.py`: Customizes the Django admin for poll management.\n    - `urls.py`: Defines the URL patterns for the poll app.\n    - `tests.py`: Contains test cases for the app.\n    - `__init__.py`: Makes the directory a Python package.\n    - `apps.py`: Configuration for the app.\n    - `templates/polls/`: Contains the HTML templates for the app's views.\n      - `index.html`: Homepage with a list of polls.\n      - `detail.html`: Poll details and voting form.\n      - `results.html`: Poll results with vote distribution.\n    - `static/`: (Optional) Stores static files like CSS for styling.\n      - `images/`: Contains images used in the app.\n      - `polls/style.css`: CSS file for styling the app.\n    - `migrations/`: Contains database migration files.\n- **`PollApplication/`:**\n    - `settings.py`: Contains the project settings and configurations.\n    - `urls.py`: Defines the URL patterns for the entire project.\n    - `wsgi.py`: WSGI configuration for deployment.\n    - `asgi.py`: ASGI configuration for deployment.\n    - `__init__.py`: Makes the directory a Python package.\n- **`db.sqlite3`:** The default SQLite database file.\n- **`manage.py`:** A command-line utility for interacting with the project.\n\n## Customization\n\n- **Templates:** Modify the HTML templates (`index.html`, `detail.html`, `results.html`) to customize the look and feel of the poll pages.\n- **Styling:** Add more CSS rules to `style.css` or create new stylesheets for further customization.\n- **Functionality:** Extend the models or views to add more features like user authentication, poll comments, or social media sharing.\n\n## REST API Usage\n\nThis app also includes a REST API built with Django REST Framework (DRF). Here are the available endpoints:\n\n| Endpoint               |        Methods         | Description                                 | Authentication Required |\n|:-----------------------|:----------------------:|:--------------------------------------------|:-----------------------:|\n| `/api/questions/`      | GET, POST, PUT, DELETE | List/create/update/delete questions.        |            ✅            |\n| `/api/questions/\u003cid\u003e/` |    GET, PUT, DELETE    | Retrieve/update/delete a specific question. |            ✅            |\n| `/api/choices/`        | GET, POST, PUT, DELETE | List/create/update/delete choices.          |            ✅            |\n| `/api/choices/\u003cid\u003e/`   |    GET, PUT, DELETE    | Retrieve/update/delete a specific choice.   |            ✅            |\n\n**Example Usage (with curl):**\n\n```bash\n# Get all questions\ncurl http://127.0.0.1:8000/api/questions/\n\n# Get a specific question\ncurl http://127.0.0.1:8000/api/questions/1/\n```\n\nFor example, if you run `curl http://127.0.0.1:8000/api/questions/`, you will get this output: \n\n```json\n[{\"id\":3,\"question_text\":\"huhu\",\"pub_date\":\"2024-06-10T07:21:01Z\"},{\"id\":4,\"question_text\":\"hehehehe\",\"pub_date\":\"2024-06-11T15:01:59Z\"},{\"id\":5,\"question_text\":\"What is the capital of France?\",\"pub_date\":\"2024-06-11T15:11:04Z\"}]\n```\n\nYou can also directly visit the API endpoints in your browser: \n\n\u003cp align=\"center\" style=\"cursor: pointer\"\u003e\n    \u003cimg src=\"readme-images/api.png\" alt=\"API Interface\" style=\"border-radius: 10px\" width=\"100%\"/\u003e\n\u003c/p\u003e\n\n**Authentication:**\nTo use POST, PUT, or DELETE methods, you'll need a valid token, typically obtained after user login. Include this token in the Authorization header:\n  \n```bash\ncurl -X POST -H \"Authorization: Token \u003cyour_token\u003e\" -H \"Content-Type: application/json\" -d '{\"question_text\": \"Is this a new question?\", \"pub_date\": \"2023-12-12T12:00:00Z\"}' http://127.0.0.1:8000/api/questions/\n```\n\n## Contributions\n\nContributions are welcome! Feel free to open issues or submit pull requests. Feel free to also fork and customize this repo to fit your needs.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE). \n\n## Contact\n\nIf you have any questions about this project or Django (or even the Django REST Framework) in general, feel free to [contact me](mailto:info@movie-verse.com)! I'll be happy to answer any questions you might have (hopefully I'll know the answers to them...)\n\n---\n\nThank you for visiting today! Created with ❤️ in 2024 by [Son Nguyen](https://github.com/hoangsonww).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoangsonww%2Fdjango-poll-application","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoangsonww%2Fdjango-poll-application","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoangsonww%2Fdjango-poll-application/lists"}