django-tiamat
A collection of utilities to help in Django Projects
Installation
pip install django-tiamat
Add to your Python path or setup.py install and add 'tiamat' to your INSTALLED_APPS setting.
Usage
This is intended for general use in any project to save time writing helpers that are common to most projects.
View Decorators
as_json will return a JSON response:
from tiamat.decorators import as_json
@as_json
def some_view(request):
#do something
return {'key': 'value'}
as_jsonp will return a JSONP response:
from tiamat.decorators import as_jsonp
@as_jsonp('callback')
def some_view(request):
#do something
return {'key': 'value'}
`http://.../?callback=myFunctionCall`
returns `myFunctionCall({"foo": "1"})`
Model Mixins
SlugMixin will add a slug field (named slug) to your model that will be automatically generated from a field called ‘name’ on saving. If you wish to override the default field to generate the slug from set make_slug_from on the model. See the source for more details.
Generic Manager
A simple way to add a manager that overrides the queryset returned.
So this:
class SomeManager(models.Manager):
def get_query_set(self):
return super(SomeManager, self).get_query_set().filter(this=that)
class SomeModel(models.Model):
# define the model
objects = models.Manager()
custom_objects = SomeManager()
Becomes this:
from tiamat.models import GenericManager
class SomeModel(models.Model):
# define the model
objects = models.Manager()
custom_objects = GenericManager(this=that)
Pagination Helper
A simple way to handle pagination of your querysets:
from tiamat.paginate import page_objects page = page_objects(Something.objects.all(), 25, 2)
Where 25 is objects per page and 2 is the current page number
ID Encoder
This is a good when you are using IDs in your urls. An example would be a link generated to confirm an email address, or a link generated to reset a user’s password.
Make sure you set the setting URL_ENCODER_KEY to something different than your SECRET_KEY then you can:
from tiamat.urlencoder import encoder encoder.encode_id(id) encoder.decode_id(identifier_string)
send_async_email provides an easy helper to send email using a template:
from tiamat.mail import send_async_email
send_async_email(
'path/to/template.html',
{'name': 'Steve'},
'Hello',
[user.email for user in User.objects.all()]
)
More?
See the source code for more.
Need Help?
Email: rvause@gmail.com
Metadata
Release files for django-tiamat 0.9.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-tiamat-0.9.8.tar.gz | 8.2 kB | Without provenance | Details for django-tiamat-0.9.8.tar.gz |
Release files / django-tiamat-0.9.8.tar.gz
| Download URL | django-tiamat-0.9.8.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
545d5ceb5f01a7370b82985d31590219c8bfccab5a406aea485d44460e5a2a80
|
|
BLAKE2b-256 checksum How to use checksums |
e789685b351f56d21a90ab5bc87c004b6f2ff8579b0c069de341e5f11b6ca81b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-tiamat 0.9.8
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.