Skip to main content

https://github.com/idlesign/django-xross

https://img.shields.io/pypi/v/django-xross.svg https://img.shields.io/pypi/dm/django-xross.svg https://img.shields.io/pypi/l/django-xross.svg https://img.shields.io/coveralls/idlesign/django-xross/master.svg https://img.shields.io/travis/idlesign/django-xross/master.svg https://landscape.io/github/idlesign/django-xross/master/landscape.svg?style=flat

Description

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 views.py:

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>
<html>
<head>
    <!-- xross depends on jQuery. Include it. -->
    <script src="http://yandex.st/jquery/2.1.1/jquery.min.js"></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.
    </script>
</head>
<body>
    <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.
         -->
    </div>
</body>
</html>

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

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

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

Documentation

http://django-xross.readthedocs.org/

Metadata

Release files for django-xross 0.6.0

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-xross 0.6.0
File Size Uploaded
django-xross-0.6.0.tar.gz 22.2 kB Details

Release files / django-xross-0.6.0.tar.gz

Download URL django-xross-0.6.0.tar.gz
Size 22.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9bf8d05be7552a7095da29058662b20a5d37613e170244b8cb6544bdfe613a18
BLAKE2b-256 checksum
How to use checksums
9ba1c96345f75a7fcb279a619ddfb11fde247029b63fc11da158973c93531984
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.6.0 This release

1 release file

0.5.1

1 release file

0.5.0

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

1 release file

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