{"id":21561458,"url":"https://github.com/phpdude/django-render","last_synced_at":"2025-04-10T11:53:30.504Z","repository":{"id":2686629,"uuid":"3679342","full_name":"phpdude/django-render","owner":"phpdude","description":"Django templates render sugar. Supports functional \u0026 class based views. (not mantained, use https://github.com/phpdude/django-template-names instead of this please)","archived":false,"fork":false,"pushed_at":"2015-04-20T08:31:18.000Z","size":160,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T10:47:57.657Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phpdude.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-03-10T12:30:34.000Z","updated_at":"2016-07-10T03:06:53.000Z","dependencies_parsed_at":"2022-07-18T23:18:23.394Z","dependency_job_id":null,"html_url":"https://github.com/phpdude/django-render","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpdude%2Fdjango-render","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpdude%2Fdjango-render/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpdude%2Fdjango-render/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpdude%2Fdjango-render/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpdude","download_url":"https://codeload.github.com/phpdude/django-render/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248215193,"owners_count":21066622,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T09:22:49.390Z","updated_at":"2025-04-10T11:53:30.488Z","avatar_url":"https://github.com/phpdude.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Render: render sugar for Django\n==========================================\n\nThis package provides decorators for templates rendering and CBV mixin in request context with simple code use.\n\n__Important:__ all template renders goes in request context. Sessions, cookies, meta, etc is available from templates.\n\nInstallation\n------------\n\nYou can install library via pip.\n\n    pip install django-render\n\nSupports coffin (jinja2 adapter for django)\n-------------------------\n\nYou can select template render engine via settings.py directive.\n\n    RENDER_ENGINE='coffin'\n\ndjango-render will use coffin adapter for rendering templates transparent.\n\nUsage in functional views\n-------------------------\n\nIt support simple template rendering with decorator function. It is basic use example. Will be\nrendered template \"APPNAME/VIEWNAME.html\"\n\n    from render.mixins import render\n    @render\n    def index():\n        #index view logic goes here\n        return {\n            'var1': val1,\n            'var2': val2,\n        }\n\n    from render.mixins import render\n    @render\n    def index():\n        #index view logic goes here\n        return {\n            'var1': val1,\n            'var2': val2,\n        }, 'text/plain'\n\nYou can override VIEWNAME part in template path. See example.\n\n    from render.mixins import render\n    @render\n    def all():\n        #all view logic goes here\n        return 'index.html', {\n            'var1': val1,\n            'var2': val2,\n        }\n\nYou can override APPNAME part in template path. See example.\n\n    from render.mixins import renderer\n    @renderer(\"otherapp\")\n    def all():\n        #all view logic goes here\n        return 'index.html', {\n            'var1': val1,\n            'var2': val2,\n        }\n\nOr you can return \"ready to use HttpResponse\" object. render wrapepr just return it.\n\n    from render.mixins import render\n    @render\n    def all():\n        if some_logic:\n            return HttpResponse(\"It's ok too\")\n        #all view logic goes here\n        return 'index.html', {\n            'var1': val1,\n            'var2': val2,\n        }\n\nUsage in Class Based Views\n--------------------------\n\nIt supports basic TemplateView's like\n\n    class Index(RenderViewMixin, TemplateView):\n        pass\n\nIt calculates template name as APP/VIEW.html\n\nYou can override heuristic by declaring template_name variable like\n\n    class Index(RenderViewMixin, TemplateView):\n        template_name = 'custom.html'\n\nThis call APP/custom.html. Or you can add full template path like\n\n    class Index(RenderViewMixin, TemplateView):\n        template_name = 'otherapp/custom.html'\n\nThen will be called 'otherapp/custom.html'\n\nLike functional view you can use render sugar in get/post/delete/etc request to your CBV.\n\n    class Index(RenderViewMixin, TemplateView):\n        def get(self, request, *args, **kwargs):\n            return {\n                \"title\": 'My awesome title!'\n            }\n\nSupported all sugar with defining template name, context data and mimetype.\n\n    class Index(RenderViewMixin, TemplateView):\n        def get(self, request, *args, **kwargs):\n            return 'print.html', {\n                \"title\": 'My awesome title!'\n            }, 'text/plain'\n\nIt works and with global template_name defining.\n\n    class Index(RenderViewMixin, TemplateView):\n        template_name = 'default.html'\n        def get(self, request, *args, **kwargs):\n            return {\n                \"title\": 'My awesome title!'\n            }, 'text/plain'\n\nTemplate processing\n-------------------\n\nInto template context render add few variables.\n\n*  __App__ - Application name, where was called view\n*  __View__ - View function name\n*  __Layout__ - Base layout path. Compiles from APPNAME and base.html. Example: for news app it will be equal \"news/base.html\"\n\nExample in template:\n    {% extends Layout %}\n\n    \u003cdiv class=\"{{ App }}_{{ View }}\"\u003e{% block content %}\u003c/div\u003e\n\nIt is clean \u0026 dry helper! Use it :-)\n\nphpdude\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpdude%2Fdjango-render","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpdude%2Fdjango-render","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpdude%2Fdjango-render/lists"}