djangosnippets.org: Latest snippets posted by lawgonhttps://djangosnippets.org/users/lawgon/2009-11-09T18:24:47.303492-06:00lawgonlanguage switcher in admin
2009-11-09T18:24:47.303492-06:00lawgonhttps://djangosnippets.org/snippets/1787/<p>you have a multilingual site and need to change languages in admin. Previously this was easy in the site itself and more difficult in admin. Now it is dead easy. Set up your languages in settings.py. Make a directory called 'admin' in your templates directory, copy ~/django/contrib/admin/templates/base.html to that directory. …</p>
Freely redistributabledjango on tornado
2009-09-29T20:40:00.851163-05:00lawgonhttps://djangosnippets.org/snippets/1748/<p>there have been many posts on running django on tornado with static media served by nginx. But for dumb people like me, the whole thing needs to be spelt out. So here is how I succeeded in serving django from a virtual host using nginx and tornado. The key thing …</p>
Freely redistributableautomating twitter
2009-07-01T04:34:56.096397-05:00lawgonhttps://djangosnippets.org/snippets/1607/<p>Assume you have a model called Delegate and you want to tweet whenever a new Delegate registers, the code above will do this. You need to install python-twitter.</p>
Freely redistributablesimple jquery example
2008-04-23T06:24:56.112320-05:00lawgonhttps://djangosnippets.org/snippets/717/<p>Displays an input with an add button. Clicking the add button creates a simple form - input with a submit button. Clicking the submit button will send the output to the server and return a value which is displayed.</p>
Freely redistributableManyToMany field with newforms
2007-11-25T00:35:14.543489-06:00lawgonhttps://djangosnippets.org/snippets/484/<p>In editing a ManyToMany field in a form, it is necessary to clear the entries in the bridge table before adding new entries. So first save the new entries, remove the old entries in the multiple choice field and then add the new entries. It is also necessary to add …</p>
Freely redistributablemultiple model form with image
2007-11-14T22:49:29.793290-06:00lawgonhttps://djangosnippets.org/snippets/463/<p>You have two models, one of which also has an image field. You want to get the data into a form and edit it. This also requires showing the url of the image, if there is one, on the form. This is a complete working example. No big deal, but …</p>
Freely redistributableChanging field type in production
2007-04-17T22:44:26.526194-05:00lawgonhttps://djangosnippets.org/snippets/188/<p>Assume a model called 'Child' with a field called 'schoolstd' whic h is of integer type and not null. You need to change it to char type and not null and the same time preserve the data. The above snippet does this in postgresql.</p>
Freely redistributable