CARVIEW |
Select Language
HTTP/2 200
server: nginx
content-type: text/html;charset=utf-8
cache-control: must-revalidate
expires: Fri, 01 Jan 1999 00:00:00 GMT
set-cookie: trac_form_token=f125170b5c162a6add87ae7f; HttpOnly; Path=/; Secure
set-cookie: trac_session=c41628b80273604c711c7112; expires=Wed, 29 Oct 2025 12:41:56 GMT; HttpOnly; Path=/; Secure
strict-transport-security: max-age=31536000; includeSubDomains; preload
permissions-policy: interest-cohort=()
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
accept-ranges: bytes
via: 1.1 varnish, 1.1 varnish
date: Thu, 31 Jul 2025 12:41:56 GMT
x-served-by: cache-fra-etou8220049-FRA, cache-bom-vanm7210086-BOM
x-cache: MISS, MISS
x-cache-hits: 0, 0
x-timer: S1753965717.589071,VS0,VE216
vary: Accept-Encoding
MyghtyTemplatesInDjango – Django
Back to Top
Django
The web framework for perfectionists with deadlines.
Issues
Using Myghty templates in Django is easy.
- Install Myghty - Myghty.org
- edit yours views like this:
import myghty.interp as interp from django.http import HttpResponse interpreter = interp.Interpreter( data_dir = '/path/to/cache', # cache folder component_root = '/path/to/templates', # templates folder ) def my_view(request): response = HttpResponse() # A file-like object interpreter.execute('mytemplate.myt', out_buffer = response) return response
It will use selected template.
You may also pass variables to the templates like this:
interpreter.execute('mytemplate.myt', out_buffer = response, request_args = {'foo' : 'banana'})
for a template looking like this:
<%args> foo </%args> %m.write(foo)
This example shows how to execute a myghty template and pass the result to django template :)
from django.shortcuts import render_to_response import myghty.interp as interp interpreter = interp.Interpreter( data_dir = './cache', # path to cache dir component_root = '/path/to/myghty/templates', ) class AFile(object): """I'm a file :) from https://blog.zabiello.com""" __content = '' def write(self, txt): self.__content += txt def read(self): return self.__content def myview(request): file = AFile() #execute a template interpreter.execute('mytemplate.myt', out_buffer = file) # show it via django template return render_to_response('index.html', {'content': file.read()})
Last modified
19 years ago
Last modified on Aug 15, 2006, 2:19:32 PM
Note:
See TracWiki
for help on using the wiki.
Download in other formats:
Django Links
Learn More
Get Involved
Follow Us
- Hosting by In-kind donors
- Design by Threespot &
© 2005-2025 Django SoftwareFoundation unless otherwise noted. Django is a registered trademark of the Django Software Foundation.