View

Setup

First of all, create a comet template:

<!-- apps/core/comets/pages/New.html -->
<div>
  {$ variable $}
</div>

Learn more about Comet template.

Define a view:

# apps/core/views.py
from picomet.decorators import template
from picomet.views import render

@template("pages/New")
def new(request):
    context = {"variable": "hello world"}
    return render(request, context)

Configure url:

# apps/core/urls.py
from django.urls import path

from core import views

app_name = "core"

urlpatterns = [
    path("new", views.new, name="new"),
]

Redirect

class picomet.http.PicometResponseRedirect

Parameter

Description

redirect_to: str

Path to redirect

update: bool = True

Whether to update the page after redirection

headers: dict = None

Http headers to be sent with the response

# apps/core/views.py
from django.contrib.auth.forms import UserCreationForm
from picomet.http import PicometResponseRedirect

@template("Index")
def index(request):
    if request.method == "POST" and not request.action:
      form = UserCreationForm(request.POST)
      if form.is_valid():
          form.save()
          return PicometResponseRedirect("/acount")

Note

PicometResponseRedirect can only be returned when request.targets has any targets or request.action exists.