Rest Framework Latex

A LaTeX renderer for Django REST Framework
Alternatives To Rest Framework Latex
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Python 100 Days135,076
a month ago682Python
Python - 100天从新手到大师
Django Rest Framework25,64924,5951,5082 days ago134December 15, 2021132otherPython
Web APIs for Django. 🎸
Awesome Django7,045
2 days ago2cc0-1.0HTML
A curated list of awesome things related to Django
Drf Yasg3,0922907616 days ago59October 25, 2020235otherPython
Automated generation of real Swagger/OpenAPI 2.0 schemas from Django REST Framework code.
Django Rest Swagger2,5162,031413 years ago50April 30, 2018168bsd-2-clausePython
Swagger Documentation Generator for Django REST Framework: deprecated
Django Rest Auth2,3311,1092410 months ago25April 01, 2019234mitPython
This app makes it extremely easy to build Django powered SPA's (Single Page App) or Mobile apps exposing all registration and authentication related functionality as CBV's (Class Base View) and REST (JSON)
Djoser2,28821257 days ago48October 30, 2020166mitPython
REST implementation of Django authentication system.
Drf Nested Routers1,4876212910 days ago19October 15, 202146apache-2.0Python
Nested Routers for Django Rest Framework
Cookiecutter Django Rest1,405
7 hours ago4mitPython
Build best practiced apis fast with Python3
Drf Extensions1,371323145 days ago16July 30, 202175mitPython
DRF-extensions is a collection of custom extensions for Django REST Framework
Alternatives To Rest Framework Latex
Select To Compare


Alternative Project Comparisons
Readme

REST Framework LaTeX Plugin

CircleCI PyPI version Documentation Status

A simple plug-n-play LaTeX renderer for Django REST Framework.

Documentation

Installing

REST Framework LaTeX can be downloaded from PyPI:

pip install rest-framework-latex

Dependencies

Currently the LaTeX plugin requires lualatex - to install this on Ubuntu:

sudo aptitude install texlive-latex-extra texlive-xetex

This will probably take some time due to the size of LaTeX (around 1GB)

Using the Renderer

You can then configure the renderer in your settings or on each view:

REST_FRAMEWORK = {
  'DEFAULT_RENDERER_CLASSES': [
    'rest_framework_latex.renderers.LatexRenderer',
  ]
}

LATEX_RESOURCES Setting

The LATEX_RESOURCES directory contains the base template environment e.g. any images or static resources to include in your template. This must be set for the renderer to work:

LATEX_RESOURCES = '/home/user/path_to_resources'

This works just like TemplateHTMLRenderer but by setting a latex_name on your view:

from rest_framework import viewsets

from rest_framework_latex import renderers


class SomeViewSet(viewsets.ViewSet):
  """
  """
  renderer_classes = [
    renderers.LatexRenderer,
  ]

  latex_name = 'directory/latexfile.tex'

Latex Templates

To use the template tags, add rest_framework_latex to your INSTALLED_APPS:

INSTALLED_APPS = [
  ...
  'rest_framework_latex',
  ...
]

The TeX file used for rendering will be pushed through Django's templating system. This will cause some issues whereby you want to do something like:

\textt{{{ some_variable }}}

To get around this issue you will need to do something like the following:

\textt{% templatetag openbrace %}{{ some_variable }}{% templatetag closebrace %}

Included Tags

Tag Tag/Filter Purpose
latex_safe Filter Escape all user-entered content for LaTeX rules
latex_resources Tag Print the value of settings.LATEX_RESOURCES

How it works

The renderer works by creating a new temporary directory, and then copying over the LATEX_RESOURCES directory into the new temporary directory.

Next it renders the TeX file into the temporary directory.

Then it runs lualatex over the TeX file, and this will produce the PDF file we read into memory.

Then we delete the temporary directory and return the PDF to the client.

Django Compatibility

The REST Framework LaTeX plugin is compatible with Django 1.11 and up and Django REST Framework 3.3 and up.

Popular Rest Projects
Popular Django Projects
Popular Application Programming Interfaces Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Python
Django
Rest
Tex
Latex
Renderer
Django Rest Framework