Couldn't get the original to work, and wanted more functionality (scale on x or y coordinates)
<img src="{{ object.image.url }}" alt="original image">
<img src="{{ object.image|thumbnail:"250w" }}" alt="image resized to 250w x (calculated/scaled)h ">
<img src="{{ object.image|thumbnail:"250h" }}" alt="image resized to (calculated/scaled)w x 250h h ">
<img src="{{ object.image|thumbnail:"250x200" }}" alt="image resized to 250wx200h ">
<img src="{{ object.image|thumbnail }}" alt="image resized to default 200w (or whatever you default it to) format">
Original http://www.djangosnippets.org/snippets/192/
Adapted http://www.djangosnippets.org/snippets/955/
Sampled From:
http://batiste.dosimple.ch/blog/2007-05-13-1/
http://vaig.be/2008/05/17/stdimagefield-improved-image-field-for-django/
As a quick, simple way to take a list of items make a table with n items per row I added a custom template filter for modulo of an integer.
To make the custom filter first create a "templatetags" directory in your application folder then add an empty file called "__init__.py" in that new directory. Finally add a file "myapp_tags.py" with the above code in it.
In the template you load your custom filter with {% load pictures_tags %} and then you can make a table with n elements per row using a simple for loop and in if statement.
This works because if ( for_loop.counter modulo n ) is zero ("if not" evaluates to True on zero values), then it makes a new table row. You might note that if the number of items in list is a multiple of n, there will be an empty row at the end... preventing that adds needless complexity so I left that out!
All you need to do is include the file you save this as in your other templates. The css and javascript is right in the file. Fully customizable. Very easy.
Click a date to choose a single date. Click a second date to choose a range. A third click will act as a first click.
note: you also will want to customize the django template specific variables in elements with ids:
s_date
e_date
cal_month
if you change those, it's not even really django specific, but i use this in my form for time off requests at work.
This helps you remove the extra comments fields from appearing in the form. If you used just form they would appear. This is for Django 1.0 + only.
By [Dipankar Sarkar](http://dipankar.name)
[Blog](http://desinerd.com)
[email protected]
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 ;)
JavaScript template for [GoogleAdmin](http://www.djangosnippets.org/snippets/1144/). Also requires the [google.html](http://www.djangosnippets.org/snippets/1145/) template. Install in `gis/admin` somewhere in your template path.
HTML template for [GoogleAdmin](http://www.djangosnippets.org/snippets/1144/). Also requires the [google.js](http://www.djangosnippets.org/snippets/1146/) template. Install in `gis/admin` somewhere in your template path.
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.
This is a fairly small bit template that, if placed in your_project_dir/templates/admin/prepopulated_fields_js.html will override the template that is normally pulled by the preopulated fields templatetag in the admin. The result is that you can successfully specify a ForeignKey or other field involving choices as a source for prepopulate_from in your admin.py. It works just as well when there are multiple fields of both the text and choice variety.
This snippet uses the [django-environment project](http://code.google.com/p/django-environment/). Django-environment is used to provide "environment variables" to django apps.
Based on [this snippet](http://www.djangosnippets.org/snippets/660/), adapted to split a list into *n* number of sublists, e.g. split a list of results into three evenly-divided sublists to enable display of the results in three columns on one page with CSS.
Tag: `{% list_to_columns your_list as new_list number_of_columns %}`
The split_seq solution comes from a comment by Sebastian Hempel on [this post](http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/425397).
More info [here](http://herself.movielady.net/2008/07/16/split-list-to-columns-django-template-tag/).
Extension of the idea from [WuzHere example from Google IO](http://code.google.com/p/wuzhere/) about creating one compressed js or css file. Original code used not very elegant if statements. I've changed it to template tags. On production server it will also use current version id.
Insert code in *cssjs.py* file in *templatetags* dir in your application and use as below (more details in docs):
`<script type="text/javascript" src="/media/jsmergefile.js"></script>`
**This code does not compress CSS and JS on the fly, because GAE is read-only and using Datastore is too heavy.**
A lot of people new to Django don't realize that `manage.py` is [just a wrapper](http://www.djangoproject.com/documentation/django-admin/) around the `django-admin.py` script installed with Django and isn't needed.
(You may need to symlink `django-admin.py` to someplace in your system `PATH` such as `/usr/local/bin`.)
The most important thing it does is to set your `PYTHONPATH` and `DJANGO_SETTINGS_MODULE` environment variables before calling `django-admin.py`. Those same settings are needed when you move your site on to a production server like Apache, so it is important to know how they work.
This shell function sets those variables for you. Put it in your `.zshrc` or bash startup script. It works for both the monolithic project style and the lightweight app style of Django development [[1](http://www.pointy-stick.com/blog/2007/11/09/django-tip-developing-without-projects/)], [[2](http://www.b-list.org/weblog/2007/nov/09/projects/)].
This function isn't fancy; drop a comment if you have an improvement. Written for zsh and tested with bash 3.1.17.
This custom filter takes in a string and breaks it down by newline then makes each separate line an item in an unordered list.
Note that it does not add the <ul> </ul> tags to give the user a chance to add attributes to the list.
This is based of the 'linebreaks' filter built in django