# Path: examples/examples/models.py
# class Foo(models.Model):
#     name = models.CharField(max_length=255)
#     a = models.IntegerField()
#     b = models.BooleanField()
# 
# class Bar(models.Model):
#     b = models.ForeignKey(Foo, on_delete=models.CASCADE)
#     c = models.CharField(max_length=255)


from os.path import dirname, abspath, join
from tri.struct import Struct
from django.http import HttpResponse
from django.utils.safestring import mark_safe
from django.utils.html import format_html
from .models import Foo, Bar
from tri_form import Form, Field, Link, choice_parse
from tri_form.views import create_object, edit_object
            "{}: {}",
            name,
            bound_field.value
        )
        for name, bound_field in form.fields_by_name.items()))

    return HttpResponse(format_html(
        """
            <html>
                <body>
                    {}
                    {}
                </body>
            </html>
        """,
        form.render(),
        message))


def example_2(request):
    return create_object(request, model=Foo)


def example_3(request):
    return edit_object(request, instance=Foo.objects.all().first())


def example_4(request):
    return edit_object(
        request,

# Path: examples/examples/models.py
# class Foo(models.Model):
#     name = models.CharField(max_length=255)
#     a = models.IntegerField()
#     b = models.BooleanField()
# 
# class Bar(models.Model):
#     b = models.ForeignKey(Foo, on_delete=models.CASCADE)
#     c = models.CharField(max_length=255)


# Path: examples/examples/views.py
from os.path import dirname, abspath, join
from tri.struct import Struct
from django.http import HttpResponse
from django.utils.safestring import mark_safe
from django.utils.html import format_html
from .models import Foo, Bar
from tri_form import Form, Field, Link, choice_parse
from tri_form.views import create_object, edit_object

            "{}: {}",
            name,
            bound_field.value
        )
        for name, bound_field in form.fields_by_name.items()))

    return HttpResponse(format_html(
        """
            <html>
                <body>
                    {}
                    {}
                </body>
            </html>
        """,
        form.render(),
        message))


def example_2(request):
    return create_object(request, model=Foo)


def example_3(request):
    return edit_object(request, instance=Foo.objects.all().first())


def example_4(request):
    return edit_object(
        request,

        instance=Foo.objects.all().first(),