Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/swing-collection/swing-hello
Django Swing | Hello
https://github.com/swing-collection/swing-hello
django hello hello-world swing swing-collection
Last synced: about 1 month ago
JSON representation
Django Swing | Hello
- Host: GitHub
- URL: https://github.com/swing-collection/swing-hello
- Owner: swing-collection
- License: bsd-3-clause
- Created: 2024-06-29T08:00:11.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-10-14T07:37:53.000Z (3 months ago)
- Last Synced: 2024-11-09T14:18:55.053Z (about 2 months ago)
- Topics: django, hello, hello-world, swing, swing-collection
- Language: Python
- Homepage: https://www.swing.dj
- Size: 124 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Citation: CITATION.cff
- Codeowners: .github/CODEOWNERS.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
Swing Hello
Django Swing Collection
---
## 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, includeurlpatterns = [
...
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
{{ title }}
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;
}
{{ title }}
{{ content }}
```
---
## Project Structure
```
swing_hello/
__init__.py
admin.py
apps.py
models.py
views/
__init__.py
view_hello_response.py
view_hello_template.py
templates/
hello.html
urls.py
```---
## 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.
---