djangovue
A set of helper tags and form widgets for making django and vue play nicely.
Installation
pip install djangovue
Tags Example
class IndexView(TemplateView):
template = 'index.html'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['message'] = 'Hello from Django'
return context
{% load djangovue %}
{% load_vuejs %}
{% djangovue on %}
<div id="app">
<p>
{{ message }}
</p>
{% djangovue off %}
<p>
{{ message }}
</p>
{% enddjangovue off %}
</div>
<script>
new Vue({
el: '#app',
data: {
message: 'Hello from Vue'
}
});
</script>
{% enddjangovue%}
Widgets Example
from django import forms
from djangovue import widgets
class UserForm(forms.Form):
username = forms.CharField(
max_length=30,
widget=widgets.TextInput(
model="user.username",
modifier=widgets.TextInput.LAZY,
attrs={":disabled": "disable"},
),
)
first_name = forms.CharField(
max_length=30,
widget=widgets.TextInput(
model="user.first_name", attrs={":disabled": "disable"}
),
)
last_name = forms.CharField(
max_length=30,
widget=widgets.TextInput(
model="user.last_name", attrs={":disabled": "disable"}
),
)
gender = forms.ChoiceField(
choices=[("male", "Male"), ("female", "Female")],
widget=widgets.RadioSelect(
attrs={"v-model": "user.gender", ":disabled": "disable"}
),
)
disable = forms.BooleanField(
required=False, widget=widgets.CheckboxInput() # v-model will automatically be set to `disable`
)
Development
Should you wish to develop the library there are some helper functions within the Makefile to get you started.
make install # Installs the project dependencies including the node modules required for the DjangoVue Vue plugin
make bundle # Transpiles and bundles the DjangoVue.ts file
make test # Runs tests
make black # Applies black formatting to the project
Once installed run the following to view the examples:
cd djangovue/examples
poetry run ./manage.py runserver
Note this project uses Poetry for packaging and managing dependencies.
Release files for djangovue 0.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| djangovue-0.0.12.tar.gz | 204.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| djangovue-0.0.12-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 411.7 kB
Release files / djangovue-0.0.12.tar.gz
| Download URL | djangovue-0.0.12.tar.gz |
|---|---|
| Size | 204.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b5c0d112b5ec862c411f218c298c6c95741b0ee77d9dc0255f8c2ce03290d61
|
|
BLAKE2b-256 checksum How to use checksums |
f64ef659fa236b3690ea523073e439b6d8119e98159770dc4b5f16e1aba71711
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.3 CPython/3.8.1 Linux/5.5.4-arch1-1
|
Release files / djangovue-0.0.12-py3-none-any.whl
| Download URL | djangovue-0.0.12-py3-none-any.whl |
|---|---|
| Size | 206.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
60f04770a0c8d73df9b26384a2aa45c0549b0ac4eedfd2e7b162dfbdcd3273a9
|
|
BLAKE2b-256 checksum How to use checksums |
34099edd75c70025871b337c2e142624324f60ca1b97204cc1999483bb0497aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.3 CPython/3.8.1 Linux/5.5.4-arch1-1
|