mirror of
https://github.com/django-components/django-components.git
synced 2025-11-21 23:16:51 +00:00
docs: Add "scenarios" code examples (#1445)
Some checks are pending
Docs - build & deploy / docs (push) Waiting to run
Run tests / build (ubuntu-latest, 3.10) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.11) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.12) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.13) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.8) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.9) (push) Waiting to run
Run tests / build (windows-latest, 3.10) (push) Waiting to run
Run tests / build (windows-latest, 3.11) (push) Waiting to run
Run tests / build (windows-latest, 3.12) (push) Waiting to run
Run tests / build (windows-latest, 3.13) (push) Waiting to run
Run tests / build (windows-latest, 3.8) (push) Waiting to run
Run tests / build (windows-latest, 3.9) (push) Waiting to run
Run tests / test_docs (3.13) (push) Waiting to run
Run tests / test_sampleproject (3.13) (push) Waiting to run
Some checks are pending
Docs - build & deploy / docs (push) Waiting to run
Run tests / build (ubuntu-latest, 3.10) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.11) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.12) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.13) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.8) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.9) (push) Waiting to run
Run tests / build (windows-latest, 3.10) (push) Waiting to run
Run tests / build (windows-latest, 3.11) (push) Waiting to run
Run tests / build (windows-latest, 3.12) (push) Waiting to run
Run tests / build (windows-latest, 3.13) (push) Waiting to run
Run tests / build (windows-latest, 3.8) (push) Waiting to run
Run tests / build (windows-latest, 3.9) (push) Waiting to run
Run tests / test_docs (3.13) (push) Waiting to run
Run tests / test_sampleproject (3.13) (push) Waiting to run
This commit is contained in:
parent
71c489df8e
commit
49afdb49d6
49 changed files with 1550 additions and 260 deletions
36
docs/examples/form_submission/page.py
Normal file
36
docs/examples/form_submission/page.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from django_components import Component, types
|
||||
|
||||
|
||||
class FormSubmissionPage(Component):
|
||||
class Media:
|
||||
js = (
|
||||
"https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio,container-queries",
|
||||
"https://unpkg.com/htmx.org@2.0.7",
|
||||
)
|
||||
|
||||
template: types.django_html = """
|
||||
{% load component_tags %}
|
||||
<html>
|
||||
<head>
|
||||
<title>Form Submission Example</title>
|
||||
</head>
|
||||
<body class="bg-gray-100 p-8" hx-boost="true">
|
||||
<div class="max-w-md mx-auto bg-white p-6 rounded-lg shadow-md">
|
||||
<h1 class="text-2xl font-bold mb-4">
|
||||
Self-Contained Form Component
|
||||
</h1>
|
||||
<p class="text-gray-600 mb-6">
|
||||
This form's HTML and submission logic are all
|
||||
handled within a single component file.
|
||||
</p>
|
||||
{% component "contact_form" / %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
class View:
|
||||
def get(self, request: HttpRequest) -> HttpResponse:
|
||||
return FormSubmissionPage.render_to_response(request=request)
|
||||
Loading…
Add table
Add a link
Reference in a new issue