File size: 2,946 Bytes
a70dd2a
 
 
 
 
 
 
 
c667567
a70dd2a
c667567
4930fb3
 
 
 
 
 
 
 
c667567
a70dd2a
c667567
a70dd2a
 
 
 
4930fb3
c667567
a70dd2a
c667567
a70dd2a
4930fb3
a70dd2a
 
c667567
4930fb3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
title: Dynamic Survey App
emoji: πŸ“
colorFrom: indigo
colorTo: purple
sdk: docker
pinned: false
---

# Dynamic Survey Application

[![Hugging Face Spaces](https://img.shields.io/badge/πŸ€—%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/Nomi78600/dynamic-survey-app)

A robust and deployable web application built with Django that allows for the creation, administration, and analysis of dynamic surveys.

## Live Demo

You can view a live demo of this application deployed on Hugging Face Spaces:
[https://huggingface.co/spaces/Nomi78600/dynamic-survey-app](https://huggingface.co/spaces/Nomi78600/dynamic-survey-app)

## Key Features

- **Custom Surveys:** Create unique surveys with multiple question types, including text fields, radio buttons, and checkboxes.
- **Dynamic Interface:** A clean and simple interface for users to respond to surveys.
- **Results Visualization:** View aggregated results for each survey to gather insights.
- **Production Ready:** Securely configured and containerized with Docker for reliable deployment.
- **Automated Admin Creation:** Superuser is created automatically in production environments via environment variables.

## Technology Stack

- **Backend:** Python, Django
- **Frontend:** HTML, CSS, JavaScript (with Chart.js for visualization)
- **Database:** SQLite
- **Deployment:** Docker, Gunicorn, Whitenoise

## Local Development Setup

To run this project on your local machine, follow these steps:

1.  **Clone the repository:**
    ```bash
    git clone https://github.com/YourUsername/your-repo-name.git
    cd your-repo-name
    ```

2.  **Create and activate a virtual environment:**
    ```bash
    # For Windows
    python -m venv venv
    .\venv\Scripts\activate

    # For macOS/Linux
    python3 -m venv venv
    source venv/bin/activate
    ```

3.  **Install the dependencies:**
    ```bash
    pip install -r requirements.txt
    ```

4.  **Run database migrations:**
    ```bash
    python manage.py migrate
    ```

5.  **Create a local superuser:**
    ```bash
    python manage.py createsuperuser
    ```
    (Follow the prompts to create your local admin account.)

6.  **Run the development server:**
    ```bash
    python manage.py runserver
    ```
    The application will be available at `http://127.0.0.1:8000`.

## Usage

-   Access the admin panel at `/admin` to log in and create new surveys and questions.
-   The main page `/` lists all available surveys for users to take.
-   View the results of a survey by navigating to `/results/<survey_id>`.

## Deployment

This application is configured for deployment on Hugging Face Spaces using Docker. The `entrypoint.sh` script handles database migrations and automated admin user creation based on the following environment variables (secrets):
-   `SECRET_KEY`
-   `ALLOWED_HOSTS`
-   `CSRF_TRUSTED_ORIGINS`
-   `DJANGO_SUPERUSER_USERNAME`
-   `DJANGO_SUPERUSER_EMAIL`
-   `DJANGO_SUPERUSER_PASSWORD`