Skip to main content

Djavue

Djavue is a Django app that allows the usage of Vue files as Django Templates.

Installation

  1. Install django-djavue from pip
pip install django-djavue
  1. Add djavue to your INSTALLED APPS
INSTALLED_APPS = [
  ...,
  'djavue',
  ...
]

Quickstart

  1. Create a .vue file inside your templates folder.

  2. Write a view that loads the template

from djavue import get_vue_template

def index(request):
    template = get_vue_template('index.vue', title="Homepage")

    return template.render({"""context here"""})

## in urls.py -> path('', index, name='index')

# Or

from djavue import VueTemplate

class Index(VueTemplate):
    def get_context(self, request):
        return {"""Context here"""}

    class Meta:
        page_title = "Homepage"
        template_name = "index.vue"

## in urls.py -> path('', Index.as_view(), name='index')

Passing Context

To get context data from django to your vue file you must use the $(key) inside the template.

Example

Vue:

<template>
  <h1>My name is {{name}}</h1>
  <h2>My age is $(age)</h2>
</template>
<script>
  export default {
    data: () => ({
      name: "$(name)",
    }),
  };
</script>

Django:

from djavue.views import VueTemplate

class Index(VueTemplate):
    def get_context(self, request):
        return {'name':'Joe', 'age':20}

    class Meta:
        page_title = "Homepage"
        template_name = "index.vue"

Result:

My name is Joe

Importing

Due to some limitations when adapting Vue to Python, the import statement is different: you only need to pass the file (exactly how you would pass to the get_template). The name of the tag will be the name of the file.

<template>
  <div>
    <component-a></component-a>
    <component-b></component-b>
  </div>
</template>
<script>
  import "component-a";
  import "components/component-b";

  export default {};
</script>

Metadata

Release files for django-djavue 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-djavue 0.2
File Size Uploaded Provenance Actions
django-djavue-0.2.tar.gz 5.5 kB Without provenance Details for django-djavue-0.2.tar.gz

Release files / django-djavue-0.2.tar.gz

Download URL django-djavue-0.2.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fd804eaf4659140cb194d91489a9db7ed0477395d8a2224495479e648615a8bc
BLAKE2b-256 checksum
How to use checksums
025eeb1fa41886f5ec92d5c16966ffa1be248b2be749a44a4ac85edd7fd4d7c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.8

Security for django-djavue 0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page