What's new in Django community blogs?

First baby-steps in GeoDjango

Aug 09 2008 [Archived Version] □ Published at zerokspot.com

For a couple of days now, Django trunk finally also includes GeoDjango. A geo-spatial extension module for Django that adds – among other things – model fields and managers to easily use backends like the geo-spatial extensions for PostgreSQL, MySQL and Oracle. Let’s see, how hard it is to get it going on my little MacBook. Since I have some ideas for a couple of projects that could definitely use some GIS-enhancements, I wanted to spend some time this weekend on at least getting a really tiny app working with GeoDjango, just to see what’s all required to get it working (using a PostgreSQL database).


Django — Easily save your model instances with dumpdata and loaddata

Aug 08 2008 [Archived Version] □ Published at Useful Stuff. under tags  django

So I’ve always wanted to know how to write the XML fixtures for automatically loading my project db with initial data, but I always thought I’d have to learn something so I stayed away and simply entered test data by … Continue reading


Django — Easily save your model instances with dumpdata and loaddata

Aug 08 2008 [Archived Version] □ Published at Useful Stuff. under tags  django

So I’ve always wanted to know how to write the XML fixtures for automatically loading my project db with initial data, but I always thought I’d have to learn something so I stayed away and simply entered test data by hand. Boy was I wrong. I had to manually write shipping tables for several shipping […]


Kansas Primary 2008 recap

Aug 06 2008 [Archived Version] □ Published at Matt Croydon under tags  django journalism python

I’m winding down after a couple of very long days preparing for our coverage of the 2008 Kansas (and local) primaries. As always it’s been an exhausting but rewarding time. We’ve come a long way since the first election I wrote software for and was involved with back in 2006 (where election night involved someone […]


Eclipse 3.4 Ganymede and PDT

Aug 06 2008 [Archived Version] □ Published at zoe.vc under tags  eclipse ganymede pdt

Unfortunately there is no working and official version of the PDT release for the current Eclipse release, Eclipse 3.4 Ganymede. However it is possible to use both. I found the solution within the Digital Base blog: Simply download the nightly build of PDT and integrate it as local site in the Eclipse update manager and then install. Quite easy.


Eclipse 3.4 Ganymede and PDT

Aug 06 2008 [Archived Version] □ Published at zoe.vc under tags  eclipse ganymede pdt

Unfortunately there is no working and official version of the PDT release for the current Eclipse release, Eclipse 3.4 Ganymede. However it is possible to use both. I found the solution within the Digital Base blog: Simply download the nightly build of PDT and integrate it as local site in the Eclipse update manager and then install. Quite easy.


Django — django.contrib.auth Login Issues: Site._meta.installed / Site matching query does not exist

Aug 05 2008 [Archived Version] □ Published at Useful Stuff. under tags  django

Well, I wondered what happened here and googling was futile. Was getting errors on django.contrb.auth.views.login If Site._meta.installed: current_site = Site.objects.get_current() After reading into what that does, it pulls SITE_ID out of your settings to check what db to look into. … Continue reading


Django — django.contrib.auth Login Issues: Site._meta.installed / Site matching query does not exist

Aug 05 2008 [Archived Version] □ Published at Useful Stuff. under tags  django

Well, I wondered what happened here and googling was futile. Was getting errors on django.contrb.auth.views.login If Site._meta.installed: current_site = Site.objects.get_current() After reading into what that does, it pulls SITE_ID out of your settings to check what db to look into. Well, my django project had a SITE_ID of 2 from many months ago. Simply changed […]


Adding Your Twitter Status to a Django Site

Aug 04 2008 [Archived Version] □ Published at Ole Morten

As part of changing the layout of my blog I wanted to add my latest Twitter status to the bottom left corner. It turned out to be very straight forward. Python has an excellent Twitter API — very litle code was required.

There’s two ways you could go about doing this. The first way is to write a template tag that would fetch the latest tweet, the other to create a context processor that would provide a tweet variable to your templates. I choose the latter.

Before we can start, the Twitter API module needs to be installed. You can find both the module and installation instruction over on google code: http://code.google.com/p/python-twitter/.

Note: I had to install the SVN version as there’s a bug in python-twitter version 0.5 when using Apache — it works fine using the development server.

To set up a context processor we first need to specify where Django can find our processors. This is done using the TEMPLATE_CONTEXT_PROCESSORS setting. Add the below to your project’s settings.py file.

1
2
3
4
5
6
7
8
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS

TEMPLATE_CONTEXT_PROCESSORS = TEMPLATE_CONTEXT_PROCESSORS + (
    "mysite.blog.context_processors.latest_tweet",
)

TWITTER_USER = "omh"
TWITTER_TIMEOUT = 3600

Django has bunch of context processors already defined in its global settings. If we only specify our processor, we would remove the default ones. If you want to keep the default processors — chances are you probably do — you could either manually add them — that doesn’t feel very DRY to me, or just append them like we do above.

Since we’re already editing settings.py we’ll go ahead and add two Twitter settings, TWITTER_USER to specify your Twitter login and TWITTER_TIMEOUT to specify how often we should ask Twitter for the latest tweet.

We specified mysite.blog.context_processors.latest_tweet as the context processor location. Next up is then to create a latest_tweet method inside of context_processors.py. Here’s what context_processors.py looks like:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
from datetime import datetime
from django.conf import settings
from django.core.cache import cache
import twitter

def latest_tweet( request ):
    tweet = cache.get( 'tweet' )

    if tweet:
        return {"tweet": tweet}

    tweet = twitter.Api().GetUserTimeline( settings.TWITTER_USER )[0]
    tweet.date = datetime.strptime( tweet.created_at, "%a %b %d %H:%M:%S +0000 %Y" )
    cache.set( 'tweet', tweet, settings.TWITTER_TIMEOUT )

    return {"tweet": tweet}

Django passes a HttpRequest object as the first and only parameter to all context processors. This is why we need to take request as a parameter, however in our case we don’t use it.

The above code is checking the cache for an existing tweet object. If the cache is empty it is uses the Twitter API to fetch the latest tweet, converts the date into a datetime object and stores the tweet in the cache.

With the context processor in place you can access the tweet object from any template loaded by any of the generic views. In your own views you need to use RequestContext instead of Context, as your context class when rendering templates.

1
2
3
4
5
<div class="twitter">
    {% if tweet %}
        <p>Latest tweet from {{ tweet.date|naturalday }}: {{ tweet.text }}<p>
    {% endif %}
</div>


Już jutro wersja Django 1.0 beta 1

Aug 04 2008 [Archived Version] □ Published at Perełki Django under tags  ogólne techblog

Już jutro ma wyjść pierwsza wersja beta Django. Ostatnią bardzo ważną zmianą, było dodanie newforms-admin do drzewa głównego. Jednakże zmian jest coraz więcej. Choć nie tak dużych to równie ważnych i kłopotliwych. Lista tych rzeczy, które mnie najbardziej dotknęły. Zmiana zasady...


DjangoCon!

Aug 01 2008 [Archived Version] □ Published at Matt Croydon under tags  django journalism

I’m a little late to the announcement party, but I’ll be attending DjangoCon and sitting on a panel about Django in Journalism with Maura Chace and Matt Waite. The panel will be moderated by our own Adrian Holovaty. I think the panel will be pretty fantastic but I can’t help be just as terrified as […]


Django — Django Sniff / Django Sniffit / DjangoSniffit.org

Jul 31 2008 [Archived Version] □ Published at Useful Stuff. under tags  django django sniff djangosniffit

So just now on IRC somebody was suggesting “DjangoSniffer” (was referring to djangosnippets.org but djangosnippets is so blatantly obvious & impossible to forget, that nobody questioned it) which lead to a correction: “DjangoSniff”? which lead to me searching django+sniff on … Continue reading


Django — Django Sniff / Django Sniffit / DjangoSniffit.org

Jul 31 2008 [Archived Version] □ Published at Useful Stuff. under tags  django django sniff djangosniffit

So just now on IRC somebody was suggesting “DjangoSniffer” (was referring to djangosnippets.org but djangosnippets is so blatantly obvious & impossible to forget, that nobody questioned it) which lead to a correction: “DjangoSniff”? which lead to me searching django+sniff on google, and #1 result was: http://www.flickr.com/photos/jacqamoe/2382980232/ Django the cat, sniffing something. :D


localflavor für Österreich in Django

Jul 31 2008 [Archived Version] □ Published at zerokspot.com

Kleines Update für alle Österreicher, die Django benutzen. Seit letztem Wochenende gibt es jetzt endlich auch ein eigenes localflavor.at-Package (r8087, r8113). Zum aktuellen Zeitpunkt kommt es mit einer Select-Box für die neun Bundesländer, einem einfachen Formularfeld, das österreichische Postleitzahlen validiert, und einem Feld, das die hier gültigen Sozialversicherungsnummern akzeptiert, daher. Was heißt das im Klartext? Hier ein kleines Beispiel: @@ python @@ from django.contrib.localflavor.at.forms import ATStateSelect, ATZipCodeField, ATSocialSecurityNumberField from django import forms


Annoucning sPaste.com

Jul 31 2008 [Archived Version] □ Published at Sean's Software Blog under tags  django jquery projects python security

Tonight I am officially launching my new side project,  sPaste.com!  sPaste is a simple tool to help you quickly and securely send small snippets of data around the web.  As usual, the site is written entirely in Django on the server side and jQuery on the client side.  At the moment it is little more […]


django-planet aggregates posts from Django-related blogs. It is not affiliated with or endorsed by the Django Project.

Social Sharing

Feeds

Tag cloud

admin administration adsense advanced ajax amazon angular angularjs apache api app appengine app engine apple application security aprendiendo python architecture argentina articles asides audrey aurelia australia authentication automation backup bash basics best practices big data binary bitbucket blog blog action day blogging book books buildout business c++ cache capoeira celery celerycam celerycrawler challenges chat cheatsheet cherokee choices christianity class-based-views cliff clojure cloud cms code codeship codeship news coding command community computer computers computing configuration consumernotebook consumer-notebook continuous deployment continuous integration cookiecutter couchdb coverage css custom d data database databases db debian debugging deploy deployment deployment academy design developers development devops digitalocean django django1.7 django admin django cms djangocon django framework django-nose django-readonly-site django-rest-framework django-tagging django templates django-twisted-chat django web framework tutorials documentation dojango dojo dotcloud dreamhost dughh easy_install eclipse education elasticsearch email encoding english error europe eventbrite events expressjs extensions fabric facebook family fashiolista fedora field file filter fix flash flask foreman form forms frameworks friends fun functional reactive programming gae gallery games geek general gentoo gis git github gmail gnome goals google google app engine guides gunicorn hack hackathon hacking hamburg haskell heroku holidays hosting howto how-to howtos how-tos html http i18n igalia image imaging indifex install installation intermediate internet ios iphone java javascript jinja2 jobs journalism jquery json justmigrated kde la latex linear regression linkedin linode linux login mac machine learning mac os x markdown math memcached meme mercurial meta meteor migration mirror misc model models mod_wsgi mongodb months mozilla multi-language mvc mysql nasa nelenschuurmans newforms news nginx nodejs nosql oauth ogólne openshift opensource open source open-source openstack operations orm osx os x ottawa paas packages packaging patterns pedantics pelican penetration test performance personal personal and misc philippines philosophy php pi pil pinax pip piston planet plone plugin pony postgis postgres postgresql ppoftw presentation private programmieren programming programming &amp; internet project projects pycharm pycon pycon-2013-guide pydiversity pygrunn pyladies pypi pypy pyramid python python3 queryset quick tips quora rabbitmq rails rant ratnadeep debnath reactjs recipe redis refactor release request resolutions rest reusable app review rhel rtnpro ruby ruby on rails scala scaling science screencast script scripting security server setup shell simple smiley snaking software software collections software development south sphinx sprint sql ssh ssl static storage supervisor support svn sysadmin tag tag cloud talk nerdy to me tastypie tdd techblog technical technology template templates template tags test testing tests tip tips tools tornado training transifex travel travel tips for geeks tumbles tutorial tutorials twisted twitter twoscoops typo3 ubuntu uncategorized unicode unittest unix use user authentication usergroup uwsgi uxebu vagrant validation virtualenv virtualenvwrapper web web 2.0 web application web applications web design &amp; development webdev web development webfaction web framework websockets whoosh windows wordpress work workshop wsgi yada year-end-review znc zope