Archive for the ‘django’ Category

28Oct

Django Signals: The Rules

Posted by Elf Sternberg as django

I use Django signals a lot in my professional work, mostly to create specialized tables that track events in the ecosystem of social networking sites that I build.  For example, if I make a post on a social networking site, that causes an event that creates a signal.  That signal will be heard by, for [...]

14Oct

Rails-like environments with Django.

Posted by Elf Sternberg as django

I needed some rails-like environment settings using Django.  This is the quick and easy way to get that done.   First, after building your “settings.py” file, create an environment under your project root named “env“.   Move your settings.py file to this directory, rename it “development.py” Now, in your root directory, open up a new file named [...]

Ah, the bleeding edge.  It’s a war out there! This morning, Facebook released fbwatir. I’ve just spent the past few hours knocking it around, and have come to the conclusion that it’s pretty mega-borked but it can be saved. In fact, I now have it working with Cucumber and Firewatir. There are several major flaws [...]

23Sep

Off in the weeds again…

Posted by Elf Sternberg as Design, django, web development

Sigh. I’ve just spent the last few hours wandering around the various “open source” analytics programs trying to find the exact right fit for what I want.  I’m not finding it, which means that (headache ahead) I may have to write something myself.  There’s a django-analytics placeholder in GoogleCode, but it’s empty.  I at least [...]

We frequently write little functions that populate the Django context, and sometimes we want that context to be site-wide, and we want every page and every Ajax handler, basically everything that takes a request and spews a response, in our application to have access to that information.  It might the user’s authentication, or his authorization, [...]

Today’s little snippet: Filtering a loosely coupled many-to-many relationship.  As revealed earlier,  I don’t really “get” the difficulty with many-to-many relationships.  I don’t even get the difficulty with signals; if you define the many-to-many manually, handling signals on it is trivial compared to trying to do it manually in one of the referring classes. Today, [...]

14Sep

Arrrgh. Now, repeat after me:

Posted by Elf Sternberg as django, python, web development

Repeat after me: Registration is not Authentication is not Authorization is not Utilization. Registration is not Authentication is not Authorization is not Utilization. Registration is not Authentication is not Authorization is not Utilization. I’ll keep reminding myself of that until I figure out how to disentangle the four from this damned Facebook app.  Registering to [...]

08Sep

Small but useful Django notions…

Posted by Elf Sternberg as django, web development

If you’ve created Django Application A, and then Django Application B, it is acceptable (and even sometimes necessary) for Application B to reference Application A.  The canonical example is Django contrib.auth; everyone references that beast.  It is not acceptable for you to go and edit Application A to reference Application B.  That is officially Doin’ [...]

The correct call for posting to a user’s facebook wall with Python and pyfacebook, after you’ve established both user authentication via FacebookConnect and gotten stream_publish permission, is: request.facebook.stream.publish( message = render_to_string(template_path, fb_context), action_links = simplejson.dumps( [{'text': "Check Us Out!", 'href': "http://someurl.com"}]), target_id = ‘nf’) See that ‘nf’ down there in target_id?  It’s not on any [...]

One of the nifty things that Django provides is the {% url backreference %} syntax, which allows you to name the targets in your list of URL objects and then refer to them by an explicit name. You can sometimes use the function name instead, and Django has a way of turning the function name back into the [...]