Skip to main content

# djajax
Some helper utilities for building Ajax applications without throwing out all the nicities of Django out the window (or moving wholesale to something like Django REST Framework).

## Models

### SerializableMixin
A model mixin that gives an easy way to serialize a model or queryset to JSON.

#### to_json
Default dictionary representation of a model that can later be converted to JSON. May be overriden in a model by defining `to_json` in the model.

#### serialize (static method)
Serializes a queryset/model into a JSON-ifable dictionary. Will paginate a queryset if necessary.

## Template tags

### jsonify filter
Outputs a dictionary input a JSON object. Returns an empty obj if the template variable is empty.

```html
<script type="text/javascript">
window.onload = function() {
(function() {
var djajaxJsonData = {{ json|jsonify }};
console.log('djajaxJsonData', djajaxJsonData);
})();
}();
</script>
```

### djajax_urls tag
Outputs a dictionary of reverse lookups to urls for use in Javascript. Urls must be specified in DJAJAX_URL_REVERSE_LOOKUPS and must not need arguments.

settings.py
```python
DJAJAX_URL_REVERSE_LOOKUPS = [
'login',
'www:index',
]
```

index.html
```html
<script src="{% static 'js/djajax.js' %}"></script>

<script type="text/javascript">
window.onload = function() {
(function() {
var djajaxUrls = {% djajax_urls %};
console.log('djajaxUrls', djajaxUrls);
})();
}();
</script>
```

## HTTP responses

### JsonHttpResponse
Returns a JSON response with the correct headers set.

## View helpers

### is_idempotent
Returns whether the request is idempotent (changes state on the server) or not.

### response
Returns an appropriate AJAX response for an AJAX request.

### get_from_post_or_get
Attempts to first get a value from the POST query dictionary, and if that fails, to look at the GET querystring.


Metadata

Release files for djajax 0.0.4

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

Source distribution (sdist)

Source distribution for djajax 0.0.4
File Size Uploaded Provenance
djajax-0.0.4.tar.gz 8.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for djajax 0.0.4
File Interpreter ABI Platform
djajax-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 17.4 kB

Release files / djajax-0.0.4.tar.gz

Download URL djajax-0.0.4.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5cdf6bb6cc5dea81e4776ffd03b6cd57d3329ab9ae38fa1575ff65b490236aff
BLAKE2b-256 checksum
How to use checksums
18fe1770a066b23bbe0929109f6813e531ca33e54f3a05a78e298f3db4e0a795
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

Release files / djajax-0.0.4-py3-none-any.whl

Download URL djajax-0.0.4-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9bc4795962cd444350f34770f0f9a4e35fdd9ec078eb4d308f16bb031d7cf7a7
BLAKE2b-256 checksum
How to use checksums
069875a24542a1046622bffb1a9731164b6fbb0ba9d7aeec19fb05603729573d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

Security for djajax 0.0.4

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.

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