https://github.com/bkeating/django-templatetag-randomgen
A simple template tag to generate random numbers.
https://github.com/bkeating/django-templatetag-randomgen
Last synced: about 1 year ago
JSON representation
A simple template tag to generate random numbers.
- Host: GitHub
- URL: https://github.com/bkeating/django-templatetag-randomgen
- Owner: bkeating
- License: bsd-3-clause
- Created: 2012-04-24T08:10:47.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2012-04-27T05:45:56.000Z (about 14 years ago)
- Last Synced: 2025-05-07T23:09:12.660Z (about 1 year ago)
- Language: Python
- Size: 112 KB
- Stars: 6
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
django-templatetag-randomgen
============================
An easy way to generate random numbers and hashes inside template files.
django-templatetag-randomgen is a simple front-end to Python's [``random``](http://docs.python.org/library/random.html) module and [``os.urandom``](http://docs.python.org/library/os.html#os.urandom) function.
## Install
1. Add ``django-templatetag-randomgen`` to your ``INSTALLED_APPS``
2. Add ``{% load randomgen %}`` to the top of template files you wish to use these tags in.
## Usage
To generate a random floating point number between 0 and 1:
{% randomgen %} # e.g. 0.27684734152988466
To generate a md5 hash:
{% randomgen hash %} # e.g. 522748524ad010358705b6852b81be4c
To generate a random number between 100 and 1000:
{% randomgen 100 1000 %} # e.g. 156
To generate a random floating point within a range:
{% randomgen 100 1000 float %} # e.g. 241.05597162504844
## Authors
This template tag was written by [Ben Keating](https://github.com/bkeating/) and [Jon Parrish](https://github.com/jwparrish/).