Simple filters for generic object template blocks
Project description
The model_filters app provides you with automatically generated, stylable generic Django templates. It fills a gap left by admin and databrowse by providing filters that allow your to painlessly create templates with the following properties:
Automatically generated read-only views
Can conform to whatever URL structure you want
Can be placed as blocks on to your existing templates
Integrate well with the rest of your project
Add this to the top of any template:
{% load model_filters %}
And drop the filter anywhere you have a model instance (e.g., DetailViews):
{{ object|as_detail_html }}
Quick Reference
Installing
You can install the model_filters app from PyPI:
$ pip install django-model-filters
Settings
Modify your INSTALLED_APPS setting to include:
... model_filters, ...
If you plan on overriding any of model_filter’s default templates, remember that app_directories.Loader searches apps in the order they are specified in INSTALLED_APPS.
Usage
Near the top of any template you want to use model filters, or in a base template, include the following line:
{% load model_filters %}
Then, where you want to drop a generic model template, use:
{{ object|as_detail_html }}
Or:
{{ object_list|as_list_html }}
By default, the title on an object detail block will be the unicode representation of the object, and the title on a list will be the name of the model appended with ‘ List’. To change the title, pass in a parameter:
{{ object|as_detail_html:"My Special Object" }}
Help Out
Found a bug? File an issue at Github <https://github.com/mjumbewu/django-model-filters>. Have an improvement? Fork it and add it, or if you can’t code it, contact us to do it.
Development
Download the code and then:
$ pip install -r requirements.txt
Running Tests
Even simple packages need tests:
$ python tests.py --with-coverage --cover-package=model_filters
Run it before and after you make any changes. Try to not let that number drop.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-model-filters-0.5.1.tar.gz
.
File metadata
- Download URL: django-model-filters-0.5.1.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f374ae11f9afe2e46921986da43cb1289ff4721965ed37d75602249a71d2b451 |
|
MD5 | a7d79c98191ad69a2bc1d384733c96b7 |
|
BLAKE2b-256 | 9e53a4da6c8af99349ca7b92b64031f9c969dee4433d39ad67c9af8f10db4d03 |
Provenance
File details
Details for the file django-model-filters-0.5.1.linux-x86_64.tar.gz
.
File metadata
- Download URL: django-model-filters-0.5.1.linux-x86_64.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36a1ce5b838f98037343bfca1445467435cc23375892e5b93c9ed9bab38f8985 |
|
MD5 | 6f68b8cf4168874a5bb1ac550e1b8382 |
|
BLAKE2b-256 | 2adcb9b49be34c1d0812dbe361ac84ef545885facb9fd1aebb5847be35b82099 |