a minor remix of simon's debug footer:
<http://www.djangosnippets.org/snippets/766/>
> Adds a hidden footer to the bottom of every text/html page containing a list of SQL queries executed and templates that were loaded (including their full filesystem path to help debug complex template loading scenarios).
This version adds TextMate links : if you are working on your local machine and using TextMate you can click on the template paths and they will be opened in TextMate. This speeds up development time considerably !
also, this works with django 1.0 (simon's version got broke by the 'connect' refactor)
update: the view function is now linked
> To use, drop in to a file called 'debug_middleware.py' on your Python path and add 'debug_middleware.DebugFooter' to your MIDDLEWARE_CLASSES setting.
Contact is a parent class. Subclasses might be Company, Person, Artist, Label etc.
Basic address, email etc. fields can be added to the parent class and all subclasses will have those.
Having searched your database for contacts (undifferentiated by class) you then want to reload the chosen object as the subclass that it really is :
``thing.as_leaf_class``
This is a simple fixture that is useful for many tests.
It contains the following users:
* admin
* staff
* user0
* user1
* user2
* user3
* inactive0
* inactive1
The password of every user is the same as his username, e.g.: admin/admin
This code will allow you to use chained select boxes in the django automatic admin area. For example, you may have a product, then a category and subcategory. You'd like to create a product, and then choose a category, and then have a chained select box be filled with the appropriate subcategories.
Move Items up and down from the admin interface. Like phpBB does it with its forums.
An additional select field is added to the admin form. After the model has been saved, a model method is called (with the value of the new field), which handles the reordering.
A more detailed description and a screenshot can be found [here](http://blog.vicox.net/2008/09/04/ordering-in-django-10/).
Instructions: Set your environment variables, install graphviz, and run.
Finds all models in your installed apps and makes a handsome graph of your their dependencies based on foreignkey relationships. Django models have green outlines, yours have purple. The edge styling could be changed based on edge type.
This accepts values such as $1,000,000 and stores them to the database as integers. It also re-renders them to the screen using the django.contrib.humanize.intcomma method which takes 1000000 and turns it into 1,000,000. Useful for large currency fields where the decimals aren't really necessary.
Automatically render your view using render_to_response with the given template name and context, using RequestContext (if you don't know what this is you probably want to be using it). For example:
@render_with('books/ledger/index.html')
def ledger_index(request):
return {
'accounts': ledger.Account.objects.order_by('number'),
}
This should work as a `django.views.generic.list_detail` generic view but will produce PDF version of given template.
This code is merged code from perenzo's [example](http://www.djangosnippets.org/snippets/659/) and code from `django.views.generic.list_detail` module.
`pisa` package is required from (http://www.htmltopdf.org/download.html) with `html5lib` package and Reportlab Toolkit 2.1+
NOTE: this is code for Django 0.96. In Django 1.0 change in line 3: ObjectPaginator to Paginator
A simple way to add `date_created` and `date_modified` timestamps to a model. Adds a `date_created` timestamp when the object is first created and adds a `date_modified` timestamp whenever the item is saved.
**Note:** You might be tempted instead to use: `date_created=models.DateTimeField(default=datetime.now())` but that won't work as Python will calculate `datetime.now()` only once when it interprets your model. This means that every object created will get the same `date_created` timestamp until you restart your server.
This essentially wraps [snippet 917](http://www.djangosnippets.org/snippets/917/) (with full credit to author ncw) in a convenience function so that you can type:
admin_register(admin, namespace=globals())
or more concisely:
admin_register(admin, globals())
at the end of your admin.py file without having to register each model and admin class individually.