swing-hello


Nameswing-hello JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/scape-agency/swing-hello
SummaryA Django plugin that provides basic views for response handling and template rendering.
upload_time2024-11-30 13:40:47
maintainerNone
docs_urlNone
authorScape Agency
requires_python<4.0,>=3.10
licenseMIT
keywords django plugin views template response-handling
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            <p align="center">
    <img src="https://github.com/scape-agency/swing.dj/blob/85830584264bca52c02e1f0dcfa3648f84783805/res/swing-logo.png" width="20%" height="20%" alt="Django Swing Logo">
</p>
<h1 align='center' style='border-bottom: none;'>Swing Hello</h1>
<h3 align='center'>Django Swing Collection</h3>
<br/>

---

## Introduction

**Swing Hello** is a simple reusable Django application that provides basic views to demonstrate response handling and template rendering. It is designed to provide simple, yet effective functionality for greeting users through various forms and views. This package includes both function-based and class-based views for returning plain text and rendering templates with context. It showcases the best practices in Django app development, including internationalization, testing, and modular design.

---

## Features

- Function-based view returning a plain text "Hello!" response.
- Class-based view returning a plain text "Hello!" response.
- Function-based view rendering a template with a context.
- Class-based view rendering a template with a context.

---

## Installation

1. Ensure you have Django installed. If not, you can install it using pip:

   ```bash
   pip install django
   ```

2. Clone the repository or download the package and include it in your Django project.

## Setup

1. Add `swing_hello` to your Django project's `INSTALLED_APPS` in `settings.py`:

   ```python
   INSTALLED_APPS = [
       ...
       'swing_hello',
   ]
   ```

2. Include the `swing_hello` URLs in your project's `urls.py`:

   ```python
   from django.urls import path, include

   urlpatterns = [
       ...
       path('hello/', include('swing_hello.urls')),
   ]
   ```

---

## Usage

### Function-Based Views

- `hello_response_view`: Returns a plain text "Hello!" response.
- `hello_template_view`: Renders a template with a context.

### Class-Based Views

- `HelloResponseView`: Returns a plain text "Hello!" response.
- `HelloTemplateView`: Renders a template with a context.

### URL Patterns

The package provides the following URL patterns:

- `/hello/` - Renders the template with context using `HelloTemplateView`.
- `/hello/response` - Returns a plain text "Hello!" response using `HelloResponseView`.
- `/hello/template` - Renders the template with context using `HelloTemplateView`.

---

## Example Template

The package includes a simple HTML template `hello.html`:

```html
<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ title }}</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f4f4f4;
        }
        .container {
            background: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            text-align: center;
        }
        h1 {
            margin-bottom: 20px;
            color: #333;
        }
        p {
            color: #666;
        }
    </style>
</head>

<body>
    <div class="container">
        <h1>{{ title }}</h1>
        <p>{{ content }}</p>
    </div>
</body>

</html>
```

---

## Project Structure

``` bash
swing_hello/
├── demo/                       # This directory contains a sample Django project for testing your reusable app (swing_hello).
│   ├── manage.py               # Entry point for managing the demo project.
│   ├── demo/
│   │   ├── __init__.py
│   │   ├── settings.py         # Configuration for the demo project.
│   │   ├── urls.py             # Main URL configuration for testing.
│   │   └── wsgi.py
│   └── db.sqlite3
├── src/
│   ├── swing_hello/            # Core directory of your reusable Django app.
│       ├── __init__.py         # Initializes the Python module.
│       ├── __main__.py
│       ├── apps.py             # Defines the app configuration for Django.
│       ├── urls.py             # URLs specific to this app.
│       ├── forms/              # Contains Django forms (e.g., form_hello.py).
│       │   ├── __init__.py
│       │   └── form_hello.py
│       ├── locale/             # Holds translation files for internationalization (e.g., en, nl).
│       │   ├── en/
│       │   │   └── ...
│       │   └── nl/
│       │       └── ...
│       ├── migrations/         # Contains migration scripts for the app.
│       │   ├── __init__.py
│       │   └── ...
│       ├── static/             # Stores app-specific static files (e.g., styles.css).
│       │   └── swing_hello/
│       │       └── styles.css
│       ├── templates/          # App-specific templates (e.g., hello_template.html).
│       │   └── swing_hello/
│       │       ├── hello_form.html
│       │       └── hello_template.html
│       ├── tests/              # Test cases for the app (e.g., test_hello_form.py).
│       │   ├── __init__.py
│       │   ├── test_hello_form.py
│       │   ├── test_hello_json.py
│       │   ├── test_hello_response.py
│       │   ├── test_hello_template.py
│       │   └── ...
│       └── views/              # App views organized by functionality (e.g., view_hello_form.py).
│           ├── __init__.py
│           ├── view_hello_form.py
│           ├── view_hello_json.py
│           ├── view_hello_response.py
│           ├── view_hello_template.py
│           └── ...
├── setup.py                    # Configuration for packaging and distributing the app.
├── README.md                   # Documentation for the repository.
└── LICENSE                     # Specifies the license for the project.
```

---

## Colophon

Made with ❤️ by **[Scape Agency](https://www.scape.agency)**

### Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your changes.

### License

This project is licensed under the BSD-3-Clause license. See the [LICENSE](LICENSE) file for details.

---


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/scape-agency/swing-hello",
    "name": "swing-hello",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "Django, plugin, views, template, response-handling",
    "author": "Scape Agency",
    "author_email": "info@scapeagency.com",
    "download_url": "https://files.pythonhosted.org/packages/14/51/1f13220f05c9893ad7929aeaa3f90bfa5d63965c0865749ed34e2cfb33b7/swing_hello-0.1.3.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n    <img src=\"https://github.com/scape-agency/swing.dj/blob/85830584264bca52c02e1f0dcfa3648f84783805/res/swing-logo.png\" width=\"20%\" height=\"20%\" alt=\"Django Swing Logo\">\n</p>\n<h1 align='center' style='border-bottom: none;'>Swing Hello</h1>\n<h3 align='center'>Django Swing Collection</h3>\n<br/>\n\n---\n\n## Introduction\n\n**Swing Hello** is a simple reusable Django application that provides basic views to demonstrate response handling and template rendering. It is designed to provide simple, yet effective functionality for greeting users through various forms and views. This package includes both function-based and class-based views for returning plain text and rendering templates with context. It showcases the best practices in Django app development, including internationalization, testing, and modular design.\n\n---\n\n## Features\n\n- Function-based view returning a plain text \"Hello!\" response.\n- Class-based view returning a plain text \"Hello!\" response.\n- Function-based view rendering a template with a context.\n- Class-based view rendering a template with a context.\n\n---\n\n## Installation\n\n1. Ensure you have Django installed. If not, you can install it using pip:\n\n   ```bash\n   pip install django\n   ```\n\n2. Clone the repository or download the package and include it in your Django project.\n\n## Setup\n\n1. Add `swing_hello` to your Django project's `INSTALLED_APPS` in `settings.py`:\n\n   ```python\n   INSTALLED_APPS = [\n       ...\n       'swing_hello',\n   ]\n   ```\n\n2. Include the `swing_hello` URLs in your project's `urls.py`:\n\n   ```python\n   from django.urls import path, include\n\n   urlpatterns = [\n       ...\n       path('hello/', include('swing_hello.urls')),\n   ]\n   ```\n\n---\n\n## Usage\n\n### Function-Based Views\n\n- `hello_response_view`: Returns a plain text \"Hello!\" response.\n- `hello_template_view`: Renders a template with a context.\n\n### Class-Based Views\n\n- `HelloResponseView`: Returns a plain text \"Hello!\" response.\n- `HelloTemplateView`: Renders a template with a context.\n\n### URL Patterns\n\nThe package provides the following URL patterns:\n\n- `/hello/` - Renders the template with context using `HelloTemplateView`.\n- `/hello/response` - Returns a plain text \"Hello!\" response using `HelloResponseView`.\n- `/hello/template` - Renders the template with context using `HelloTemplateView`.\n\n---\n\n## Example Template\n\nThe package includes a simple HTML template `hello.html`:\n\n```html\n<!doctype html>\n<html lang=\"en\">\n\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>{{ title }}</title>\n    <style>\n        body {\n            font-family: Arial, sans-serif;\n            line-height: 1.6;\n            margin: 0;\n            padding: 0;\n            display: flex;\n            justify-content: center;\n            align-items: center;\n            height: 100vh;\n            background-color: #f4f4f4;\n        }\n        .container {\n            background: #fff;\n            padding: 20px;\n            border-radius: 8px;\n            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n            text-align: center;\n        }\n        h1 {\n            margin-bottom: 20px;\n            color: #333;\n        }\n        p {\n            color: #666;\n        }\n    </style>\n</head>\n\n<body>\n    <div class=\"container\">\n        <h1>{{ title }}</h1>\n        <p>{{ content }}</p>\n    </div>\n</body>\n\n</html>\n```\n\n---\n\n## Project Structure\n\n``` bash\nswing_hello/\n\u251c\u2500\u2500 demo/                       # This directory contains a sample Django project for testing your reusable app (swing_hello).\n\u2502   \u251c\u2500\u2500 manage.py               # Entry point for managing the demo project.\n\u2502   \u251c\u2500\u2500 demo/\n\u2502   \u2502   \u251c\u2500\u2500 __init__.py\n\u2502   \u2502   \u251c\u2500\u2500 settings.py         # Configuration for the demo project.\n\u2502   \u2502   \u251c\u2500\u2500 urls.py             # Main URL configuration for testing.\n\u2502   \u2502   \u2514\u2500\u2500 wsgi.py\n\u2502   \u2514\u2500\u2500 db.sqlite3\n\u251c\u2500\u2500 src/\n\u2502   \u251c\u2500\u2500 swing_hello/            # Core directory of your reusable Django app.\n\u2502       \u251c\u2500\u2500 __init__.py         # Initializes the Python module.\n\u2502       \u251c\u2500\u2500 __main__.py\n\u2502       \u251c\u2500\u2500 apps.py             # Defines the app configuration for Django.\n\u2502       \u251c\u2500\u2500 urls.py             # URLs specific to this app.\n\u2502       \u251c\u2500\u2500 forms/              # Contains Django forms (e.g., form_hello.py).\n\u2502       \u2502   \u251c\u2500\u2500 __init__.py\n\u2502       \u2502   \u2514\u2500\u2500 form_hello.py\n\u2502       \u251c\u2500\u2500 locale/             # Holds translation files for internationalization (e.g., en, nl).\n\u2502       \u2502   \u251c\u2500\u2500 en/\n\u2502       \u2502   \u2502   \u2514\u2500\u2500 ...\n\u2502       \u2502   \u2514\u2500\u2500 nl/\n\u2502       \u2502       \u2514\u2500\u2500 ...\n\u2502       \u251c\u2500\u2500 migrations/         # Contains migration scripts for the app.\n\u2502       \u2502   \u251c\u2500\u2500 __init__.py\n\u2502       \u2502   \u2514\u2500\u2500 ...\n\u2502       \u251c\u2500\u2500 static/             # Stores app-specific static files (e.g., styles.css).\n\u2502       \u2502   \u2514\u2500\u2500 swing_hello/\n\u2502       \u2502       \u2514\u2500\u2500 styles.css\n\u2502       \u251c\u2500\u2500 templates/          # App-specific templates (e.g., hello_template.html).\n\u2502       \u2502   \u2514\u2500\u2500 swing_hello/\n\u2502       \u2502       \u251c\u2500\u2500 hello_form.html\n\u2502       \u2502       \u2514\u2500\u2500 hello_template.html\n\u2502       \u251c\u2500\u2500 tests/              # Test cases for the app (e.g., test_hello_form.py).\n\u2502       \u2502   \u251c\u2500\u2500 __init__.py\n\u2502       \u2502   \u251c\u2500\u2500 test_hello_form.py\n\u2502       \u2502   \u251c\u2500\u2500 test_hello_json.py\n\u2502       \u2502   \u251c\u2500\u2500 test_hello_response.py\n\u2502       \u2502   \u251c\u2500\u2500 test_hello_template.py\n\u2502       \u2502   \u2514\u2500\u2500 ...\n\u2502       \u2514\u2500\u2500 views/              # App views organized by functionality (e.g., view_hello_form.py).\n\u2502           \u251c\u2500\u2500 __init__.py\n\u2502           \u251c\u2500\u2500 view_hello_form.py\n\u2502           \u251c\u2500\u2500 view_hello_json.py\n\u2502           \u251c\u2500\u2500 view_hello_response.py\n\u2502           \u251c\u2500\u2500 view_hello_template.py\n\u2502           \u2514\u2500\u2500 ...\n\u251c\u2500\u2500 setup.py                    # Configuration for packaging and distributing the app.\n\u251c\u2500\u2500 README.md                   # Documentation for the repository.\n\u2514\u2500\u2500 LICENSE                     # Specifies the license for the project.\n```\n\n---\n\n## Colophon\n\nMade with \u2764\ufe0f by **[Scape Agency](https://www.scape.agency)**\n\n### Contributing\n\nContributions are welcome! Please fork the repository and submit a pull request with your changes.\n\n### License\n\nThis project is licensed under the BSD-3-Clause license. See the [LICENSE](LICENSE) file for details.\n\n---\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Django plugin that provides basic views for response handling and template rendering.",
    "version": "0.1.3",
    "project_urls": {
        "Documentation": "https://swing-hello.readthedocs.io",
        "Homepage": "https://github.com/scape-agency/swing-hello",
        "Repository": "https://github.com/scape-agency/swing-hello"
    },
    "split_keywords": [
        "django",
        " plugin",
        " views",
        " template",
        " response-handling"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b1142250b16d7f2be196b91685124964575b645061d0dae900f74c4f8ac0a893",
                "md5": "ac9e24db3092062c34564082c26cdc88",
                "sha256": "462aa3c49328eded8fc4f2187987a4495d52aee94f1639da91d2d22d7084ddcf"
            },
            "downloads": -1,
            "filename": "swing_hello-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ac9e24db3092062c34564082c26cdc88",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 26312,
            "upload_time": "2024-11-30T13:40:44",
            "upload_time_iso_8601": "2024-11-30T13:40:44.887519Z",
            "url": "https://files.pythonhosted.org/packages/b1/14/2250b16d7f2be196b91685124964575b645061d0dae900f74c4f8ac0a893/swing_hello-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "14511f13220f05c9893ad7929aeaa3f90bfa5d63965c0865749ed34e2cfb33b7",
                "md5": "b5959dd7e2a70bcaf4cee7a4b8789c3e",
                "sha256": "64943b39b71909a5328a430edfcfa24ffd5a41782ee530d4a68bfd2349b34c0b"
            },
            "downloads": -1,
            "filename": "swing_hello-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "b5959dd7e2a70bcaf4cee7a4b8789c3e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 14939,
            "upload_time": "2024-11-30T13:40:47",
            "upload_time_iso_8601": "2024-11-30T13:40:47.487347Z",
            "url": "https://files.pythonhosted.org/packages/14/51/1f13220f05c9893ad7929aeaa3f90bfa5d63965c0865749ed34e2cfb33b7/swing_hello-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-30 13:40:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "scape-agency",
    "github_project": "swing-hello",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "swing-hello"
}
        
Elapsed time: 0.85939s