This code will put an entire folder into your media bundle - instead of having to write out every file in a given folder:
*It assumes your static root is a absolute directory*
**Usage**
MEDIA_BUNDLES = (
('init.js',
'coffeescript/init.coffee',
),
bundle_builder('libraries.js', 'javascript/vendor'),
bundle_builder('main.js', 'coffeescript', exclude=['init.js',]),
bundle_builder('templates.js', 'eco'),
)
**Notes**
You may wish to use [cache_utils](http://pypi.python.org/pypi/django-cache-utils) or similar to avoid crawling the filesystem every time the site loads
- django
- wildcard
- django-mediagenerator
- mediagenerator
This is just a modified version of a [previous snippet](http://djangosnippets.org/snippets/1364/) to make it work with unicode and with class-based ListView paginator_class
To use it put this in your urls.py:
`from youapp.fileyouchose import NamePaginator`
`urlpatterns = patterns('',`
`url(r'^example/(?P<page>[0-9]+)/$', ListView.as_view(model=myModel,template_name="mytemplate.html",paginator_class=NamePaginator,paginate_by=25), name="url_name"),`
And then in your template something like this would work:
{% if page_obj.has_other_pages %}
<div class="row">
<div class="span12">
<div class="pagination">
<ul>
{% if page_obj.has_previous %}
<li><a href="{% url page page=page_obj.previous_page_number %}">Prev</a></li>
{% else %}
<li class="disabled"><a>Prev</a></li>
{% endif %}
{% for p in page_obj.paginator.pages %}
<li {% if p == page_obj %}class="active"{% endif %}>
<a href="{% url category_page page=p.number %}">{{ p }}</a>
</li>
{% endfor %}
{% if page_obj.has_next %}
<li><a href="{% url page page=page_obj.next_page_number %}">Next</a></li>
{% else %}
<li class="disabled"><a>Next</a></li>
{% endif %}
</ul>
</div>
</div>
</div>
{% endif %}
- django
- pagination
- listview