Tag: tech

Aptana Studio and “Undefined variable from import: DoesNotExist”

aptana-undefined-variableIn my journey from Java hacker to a Django developer, I’ve test driven a bunch of Python IDEs (ranging from true dev tools like Aptana, Eclipse/PyDev, PyCharm to simple editors like Notepad++).

Recent I was adding some django-profile code I found via Scot Hacker’s very helpful “django-profiles: The Missing Manual“.

Continue reading »

New Django site: polurls.com

badge-mapTwo of my great passions (OK…obsessions) are web tech and politics. It was just a matter of time before I mashed them together.

Recently, I’ve been diving head first into Django, looking to complement my Java-based toolset with some Python and Django ones.

Last week I launched polurls.com, a political blog aggregator which is not only my first live Django site but also the spawn of my politics and tech love. Think of it as the popurls of politics. A site which aggregates left-leaning political blogs on polurls.com/blue, right-leaning blogs on polurls.com/red and the whole spectrum of political blogs on polurls.com/purple.

Continue reading »

Specify a custom manager for the Django admin interface

django-adminAs I was running through the weblog example in James Bennett’s excellent “Practical Django Projects (2nd Ed)” book I ran across a problem. In the book, we are asked to create a custom manager for the Entry model.

Instead of pulling all entries, the custom manager only pull the entries that have been marked as LIVE (and ignores the ones that are marked HIDDEN or DRAFT).

This custom manager is set as the _default_manager (by defining it first in the Entry class), which is fine, except for the fact that the Django admin interface “defaults” to using the default manager of a class. In the admin, I want to see and edit ALL objects, not just the live ones.

Continue reading »

Errata: Practical Django Projects 2nd Edition (PDF)

practical-django-projectsUPDATE! Even better than listing out the individual errors, Phil Gyford has posted his working code for the examples in James Bennet’sPractical Django Projects 2nd Edition“. You can find it on bitbucket here. Thanks Phil!

Since a quick Google search failed to turn up these e-book errate for James Bennets informative “Practical Django Projects 2nd Edition”, I’ll compile my own list. Hopefully my frustration in overcoming these errors will save you from the same.

Chapter 4, page 66:

(r'^weblog/(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(P?<slug>[-\w]+)/$',
'coltrane.views.entry_detail'),

should be:

(r'^weblog/(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(?P<slug>[-\w]+)/$',
'coltrane.views.entry_detail'),

(note the “P?” vs. “?P” before <slug>)

Chapter 4, page 70

Author should mention that the following must be added to the top of urls.py once you switch to generic views:

from coltrane.models import Entry

Chapter 4, page 71 and 73

Each of the four urlpatterns which include:

weblog/(?P<year>\d{4}/

Should actually be:

weblog/(?P<year>\d{4})/

(note the “)” after the {4})

Real Time Analytics