Login

All snippets written in HTML/template

78 snippets

Snippet List

update-django: Update your django git branches.

This is the (revamped) bash script I use to keep my git branches up-to-date with SVN to make my life a lot easier, just save it in a text file and read the instructions at the top! Hope it's useful to somebody else than me ;)

  • bash
  • merge
  • update
  • svn
  • git
Read More

Bootstrap theme for django-endless-pagination?

An example for using bootstrap theme for django-endless-pagination or django-el-pagination as asked on [http://stackoverflow.com/questions/30149152/how-to-set-bootstrap-theme-for-django-endless-pagination](http://stackoverflow.com/questions/30149152/how-to-set-bootstrap-theme-for-django-endless-pagination) I used django-el-pagination to make it work on Django 1.9 and Bootstrap v4.0.0-alpha2, but same method should work on django-endless-pagination. For Bootstrap 3, you may consider removing extraneous classes in <li> and <a>.

  • bootstrap
  • django-endless-pagination
  • django-el-pagination
Read More

Bootstrap theme for django-endless-pagination?

An example for using bootstrap theme for django-el-pagination as asked on http://stackoverflow.com/questions/30149152/how-to-set-bootstrap-theme-for-django-endless-pagination I used django-el-pagination to make it work on Django 1.9, but same method should work on django-endless-pagination as well.

  • bootstrap
  • django-endless-pagination
  • django-el-pagination
Read More

Admin related widget wrapper with edit / delete link (html)

Here's the python code to produce an admin related widget with the edit and delete link also. * [RelatedFieldWidgetWrapper](http://djangosnippets.org/snippets/2562) * [related-widget-wrapper.html](http://djangosnippets.org/snippets/2563) * [related-widget-wrapper.js](http://djangosnippets.org/snippets/2564) * [RelatedWidgetWrapperAdmin](http://djangosnippets.org/snippets/2565)

  • admin
  • related
  • widget
  • wrapper
Read More

Image inlining template tag example

The example of the Image inlining template tag lib which inline images in the browser instead of making an Http request. The lib is available at : [http://djangosnippets.org/snippets/2268/](http://djangosnippets.org/snippets/2268/)

  • tag
  • image
  • templatetag
  • base64
Read More

Django csrf_token Template Tag Fix

If you currently use `{% csrf_token %}`, you will notice it prints a hidden div, and an xHTML input tag. What if you don't want that hidden div, and/or you want your page to validate with HTML and not xHTML. This snippet returns only the csrf token itself, and none of the related HTML code. You can use it like this. `<input type="hidden" name="csrfmiddlewaretoken" value="{% with csrf_token as csrf_token_clean %}{{ csrf_token_clean }}{% endwith %}" >`

  • csrf_token
  • csrf_token_clean
Read More

Accordion changelist admin

Allows you to hide the filters in the pages of lists of admin. Very useful when filters hide one or more columns. Add this code after the block "extrastyle"

  • admin
  • changelist
Read More

very archive template

I tried to think of a way to use generic views to show all my blog posts on one page organized chronologically with each post title under one month name and all the month names under one year name. Like so: ` 2009 October My last example blog entry Entry even before the last one First of October September Only one entry in Sept. 2008 December It is cold in December First posting of my blog ` I could not think of a way to do this using generic views, before I wrote a view and some template logic that does. The view code is here: [http://www.djangosnippets.org/snippets/1766/](http://www.djangosnippets.org/snippets/1766/) Any suggestions for design patterns are greatly appreciated.

  • archive
  • blog-entry
Read More

improved sortby template tag

Variation on dictsort using attribute access. Nested attributes can be used, like, "obj.attr.attr_attr" Example usage: {% for entry in entries|sortby:'category.title' %} Based on [1609](http://www.djangosnippets.org/snippets/1609/)

  • template
  • tag
  • dictsort
Read More

List all Form Errors

You can place this code above your form and it will list out all errors in your form if there are errors. Sometimes I like listing the errors at the top of the form because I think it looks cleaner. Make sure you add error_messages={'required': 'My detailed error here'} in your view.py for your form.

  • error
  • form
Read More