skip to navigation
skip to content

Not Logged In

django-xross 0.4.0

Reusable application for Django nicely bridging client and server sides.


Reusable application for Django nicely bridging client and server sides.

Streamline you server and client interaction using some declarative techniques in your HTML, and a couple of xross functions in your views.

Somewhere in your

from django.shortcuts import render
from xross.toolbox import xross_view, xross_listener  # That's all we need from xross.

def list_news(request):
    """This function will be used by xross to load news using AJAX."""
    news = ...  # Here we fetch some news from DB.
    return render(request, 'mytemplates/sub_news.html', {'news': news})

@xross_view(list_news)  # Decorate your view - instruct xross to use `list_news` when needed.
def index_page(request):
    """This is our view to streamline."""

    xross_listener()  # xross will handle AJAX calls from that moment.

    return render(request, 'mytemplates/index.html')

Now to your mytemplates/index.html:

<!DOCTYPE html>
    <!-- xross depends on jQuery. Include it. -->
    <script src=""></script>

    <!-- Now xross itself. -->
    <script src="{{ STATIC_URL }}js/xross/xross.min.js"></script>
    <script type="text/javascript">
        xross.automate();  // Instruct xross to watch for page elements with `xross` class.
    <div id="list_news" class="xross">
            Contents of this div will be replaced with news from Django's `list_news()`
            automatically on page load.

            That's the default of xross, but it knows some other nice little tricks.
            Read the docs.

At last mytemplates/sub_news.html (nothing special):

{% for item in news %}
        <div>{{ item.title }}</div>
        <div>{{ item.text }}</div>
{% endfor %}

That’s not all, not at all. Read the docs!

File Type Py Version Uploaded on Size
django-xross-0.4.0.tar.gz (md5) Source 2015-03-28 18KB
  • Downloads (All Versions):
  • 11 downloads in the last day
  • 98 downloads in the last week
  • 437 downloads in the last month