This is a simple URI Querystring generator that can be used with Django for generating URI Querystring and preserving the current
Currently working to port into a template tag to allow
{% urlgen page|5 %} {% urlgen page 5 %} {% urlgen page,5 %}
OR
{% urlgen sort name display all %} etc..
This decorator is to make it's decorated function to commit the transaction on success (rollback otherwise) unless the transactions are being already managed.
This trick is for caching a view only if it passes some condition, for example, if there are more than zero items in a list. The same methodology could be used for conditional applying of other decorators.
This template filter, "jumptime" will find any timecodes in a chunk of text and convert them to links that can be used to jump a video player to that point. E.g., If there is the string "3:05", it will be converted into a link that can be used to jump to that point. This is similar to what youtube does.
For information on how to implement, see Django's [custom template tag information](http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags).
You'd use this with some javascript like this:
`jQuery(document).ready(function(){
jQuery('a.jumpToTime').bind('click',function(){
player.sendEvent('PLAY');
player.sendEvent('SEEK', jQuery(this).attr('value'));
});
});`
This is useful to run before you add a unique key to a character field that has duplicates in it. It just adds numbers to the end of the contents, so they will be unique.
It takes a model class and a field name. The model class can be a South fake orm object, so this can be used inside data migrations.
By default all forms created using inlineformset_factory are displayed as tables (because there is only a .as_table method) and there are no .as_p or .as_ul methods in them, so you need to do that by hand.
When debugging/developing you want to be able to refresh your views every time you make a little change. But when in production mode you might want to cache these views because they contain long and resource hungry calculations or something.
By putting this above "hack" in after importing `cache_page` you only cache the views in production mode.
Ripped this out of a project I'm working on. The field renders as two <select> elements representing the two-level hierarchy organized events Facebook uses. Returns the id's Facebook wants.
This code uses oracle as an authentication back end. It creates a new connection to the db and attempts to login. If successful it will then create an upper case User account with _ORACLE appended to the username.
My urls.py call:
from django.conf.urls.defaults import *
urlpatterns = patterns('',
(r'^accounts/login/$', 'django.contrib.auth.views.login',
{'template_name': 'login.html'}),
)
My setting.py specific settings:
AUTHENTICATION_BACKENDS = (
'oracleauth.views.OracleAuthBackend',
)
LOGIN_URL = '/accounts/login/'
ORACLE_CONNECT = 'database-host:1521/database'
DEBUG=True
A Django model manager capable of using different database connections.
Inspired by:
* [Eric Florenzano](http://www.eflorenzano.com/blog/post/easy-multi-database-support-django/)
* [Kenneth Falck](http://kfalck.net/2009/07/01/multiple-databases-and-sharding-with-django)
There's a more detailed version in Portuguese in my blog:
[Manager para diferentes conexões de banco no Django](http://ricobl.wordpress.com/2009/08/06/manager-para-diferentes-conexoes-de-banco-no-django/)
This snippet helps preserving query parameters such as page number when the view perform redirects.
It does not support hooking templates and contexts currently.
You're looking at the top-rated snippets currently on the site; if you'd like to contribute, sign up for an account and you'll be able to rate any snippet you see.