Negative Space: Django
- Automatically link related URLs in Django
- One of the features of my old blog and my new Django CMS is autolinking the URLs that I mention in the text.
- Code formatting Django tag
- xml.dom.minidom makes it easy to format code snippets into lists.
- Converting an existing Django model to Django-MPTT
- Using a SQL database to mimic a filesystem will, eventually, create bottlenecks when it comes to traversing the filesystem. One solution is modified preordered tree traversal, which saves the tree structure in an easily-used manner inside the model.
- Converting FileMaker to Django
- Appscript and the Django API make it easy to transfer data from Mac OS X scriptable applications into a Django-powered database.
- Custom authentication in Django
- Decorators can be used to restrict access to any view.
- Custom managers for Django ForeignKeys
- I’ve got one really annoying model for keywords. There’s one category of keywords that, by default, should not show up when used as a ForeignKey for most models. Key word: most.
- Custom ModelForms with django-ajax-selects
- It looks like django-ajax-selects has trouble with custom ModelForms if the form does not validate.
- Django 1.0 feedgenerator and unique IDs
- The new Django now supports unique_id, but still doesn’t check to see if it’s a permalink or not.
- Django actions as their own intermediate page
- The Django documentation recommends a complicated URL redirect to handle admin actions that need an intermediate page. But there’s no reason we can’t just piggy-back the intermediate page on the action itself.
- Django and Taskpaper
- The Taskpaper format is a simple, structured text format. That means it’s easy to create using Django templates.
- Django forms and edit_inline models
- Getting edit_inline models to show up on custom forms isn’t as hard as it looks. MultiValueField and MultiWidget aren’t documented well, but they do work. Here’s how I did it in Django 0.96.
- Django formsets and date/time fields
- Date/Time fields in Django formsets appear to have incompatible default values, resulting in forms using them always looking as though they’ve got a new entry when they don’t.
- Django QuerySet Heisenberg gotcha
- Observing a system changes the system. That’s especially true with Django’s QuerySet API.
- Django syndication feed guid
- Django’s syndication feed makes it fairly easy to set up a feed from any object, but it uses the object’s link as the unique ID for that object. This doesn’t always work.
- Django tutorial mostly ready
-
My long-promised Django tutorial is pretty much ready. It’s still designed around an in-person tutorial, but you should be able to get started using it even if you’re on your own.
- Django Twitter tag and RSS object
- I wanted to embed my twitter feed into my Django blog, and didn’t see any simple RSS readers for Python that did what I wanted.
- Django using too much memory? Turn off DEBUG=True!
- DEBUG=False can save hundreds of megabytes in Django command-line scripts, and probably in Django web processes.
- Django, empty strings, and missing values
- Django currently refuses to differentiate between an empty string and the absence of a value in a field. You’ll need to override your model’s save method if this distinction is important to you.
- Django: Beyond the SQL
- Django is a great application framework for Python and web applications. You can use it to greatly speed up your database and application development both on the web and on the command line. This tutorial is currently a very rough draft; it probably won’t be very useful without the assistance of someone who knows Django running the tutorial. If I ever run this tutorial a second time, I’ll probably update it with screenshots to make it more usable for individuals.
- Django: fix_ampersands and abbreviations
- The fix_ampersands filter will miss some cases where ampersands need to be replaced.
- Dynamic template content in Django fields
- It’s easy to run database content through Django’s templating system as if it were a template, before handing it off to the “real” template render. This allows you to put template tags inside of your dynamic content as well as inside template files.
- Embedding Mako into Django
- You got Mako in my Django! You got Django on my Mako! Two great templates that template great together.
- feedgenerator potentially improved
- There’s an accepted fix in the Django ticket system that will make this hack unnecessary.
- Fixing Django 1.2.4’s SuspiciousOperation on filtering
- When you get the message “Filtering by keyword not allowed” in Django 1.2.4, here’s one way to fix it.
- Fixing Django’s feed generator without hacking Django
- It looks like it’s going to be a while before the RSS feed generator in Django is going to get fixed, so I looked into subclassing as a way of getting a working guid in my Django RSS feeds.
- From Django .96.2 to 1.0
- What the Django porting guide doesn’t tell you about upgrading to 1.0.
- How useful is Django?
- I was recently asked “how do you find Django?” after mentioning that I’ve been using it extensively. The answer is by squinting a bit.
- Installing Django in Mac OS X Leopard
- If you’re looking to play around with web applications in Python, Django is a great way to start.
- ModelForms and FormViews
- This is just a notice because when I did a search, nothing came up. Don’t use ModelForm with FormView, use UpdateView instead.
- Multiple column PDF generation in Python
- You can use ReportLab’s Platypus to generate multi-column PDFs in Snakelets, Django, or any Python app.
- Multiple Input Fields with multiple inheritance
- We needed to display one TextField as either a TextInput or a Textarea, depending on the value in the field. Multiple inheritance makes it easy, if a bit wonky.
- MultiWidgets and templates in Django
- You can override the default appearance of a MultiWidget and use templates to provide a custom appearance.
- Regroup vs. IfChanged in Django templates
- Django’s regroup template tag can filter the “by” portion before regrouping to, for example, provide an alphabetical headline.
- Remembering Django form submissions when authenticating
- If you time out sessions for safety, it’s possible that you’ll time someone out and then they’ll try to submit a form. You can maintain their submission during the login process.
- Replicating Django’s admin form pop-ups
- Django’s built-in admin form lets you “add another” item in a ForeignKey or ManyToManyField by clicking a plus button. This functionality is very easy to duplicate in your own forms.
- Reusing Django’s filter_horizontal
- Just as with pop-ups, it’s possible to use the built-in JavaScript for filtering multiple-selection popups on custom forms.
- Selling Django to the Eskimos
- How do you sell Django—and by extension Python—to clients whose programmers aren’t familiar with it?
- Thinking Python: Django cache expiration time
- Django sets the expiration time when data is cached. Sometimes it makes more sense to expire data dynamically based on later changes to the database. Does this mean a change to CacheClass? Not necessarily.
- Two search bookmarklets for Django
- Bookmarklets—JavaScript code in a bookmark—can make working with big Django databases much easier.
More Information
- Django QuerySet API
-
“This document describes the details of the QuerySet API. Internally, a QuerySet can be constructed, filter, sliced, and generally passed around without actually hitting the database. No database activity actually occurs until you do something to evaluate the queryset.”
- fix_ampersands does not convert abbreviations followed by a semi-colon
-
“In django/utils/html.py, unencoded_ampersands_re will not convert ampersands if they are followed by at least one alphabetical character and a semicolon. There are no named entities with only a single character, but abbreviations of that form are common in some circles: D&D and R&D for example.”
- The Django admin site
-
“One of the most powerful parts of Django is the automatic admin interface. It reads metadata in your model to provide a powerful and production-ready interface that content producers can immediately use to start adding content to the site. In this document, we discuss how to activate, use and customize Django’s admin interface.”