Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
One step too many, or how to mess up your library
Say, you’re writing an open-source package which is going to do some pile of common tasks in applications of many developers (probably including you). For example, something for REST servers, just because my last frustration on the subject was due to a REST framework. Okay, so you’re writing these functions useful for REST: handling serialization, authentication, routing, headers, versions, et cetera. There really are lots of things you have to care about in REST, because REST is easy to get wrong, so your collection of functions and classes would come handy. Now you have some modules: one with a couple of classes for Authentication, and another with functions to serialize everything to any format out there and back, and another with whatever else REST needs to be proper. The library really seems comprehensive. You’re writing some docs, and the library slowly transforms from comprehensive to awesome. You’re enjoying pleasant thoughts about how everyone will like the library after it gets released. Finally, you’re taking a good look on your library as a whole and think: hey, it handles, like, everything you need in REST! With this thought in mind, you’re writing a function which (as you think) will save everyone … -
Good ol' SSH
I’ve recently started using a Mac as my primary computer. It’s been a fairly easy transition as most everything I work on is already *nix based and the majority of the software I use is cross-platform. One thing I did miss was PuTTY. Mostly because I could easily save sessions and invoke them with “putty -load whatever”. Meanwhile, invoking SSH manually in Terminal was a pain. Well, that turned out to be quite an easy fix. How is it that I never knew about ssh-config? Merely create a “~/.ssh/config” file and put in: Host whatever HostName whatever.wherever.com User myuser Now you can just “ssh whatever” from a Terminal window. What a relief! Next, I used to make use of “plink” as a local proxy command in PuTTY to create a tunnel through a firewall for work. How do you do this with regular SSH? Well, Google returns lots of results on how to use the ProxyCommand ssh-config option along with netcat, but that didn’t work for me. Netcat wasn’t installed on the firewall. As it turns out, and I don’t know why this was so hard to find, SSH has netcat built in. So instead of doing something like this: … -
Good ol' SSH
I've recently started using a Mac as my primary computer. It's been a fairly easy transition as most everything I work on is already *nix based and the majority of the software I use is cross-platform. One thing I did miss was PuTTY. Mostly because I could easily save sessions and invoke them with "putty -load whatever". Meanwhile, invoking SSH manually in Terminal was a pain. Well, that turned out to be quite an easy fix. How is it that I never knew about ssh-config? Merely create a "~/.ssh/config" file and put in: Host whatever HostName whatever.wherever.com User myuser Now you can just "ssh whatever" from a Terminal window. What a relief! Next, I used to make use of "plink" as a local proxy command in PuTTY to create a tunnel through a firewall for work. How do you do this with regular SSH? Well, Google returns lots of results on how to use the ProxyCommand ssh-config option along with netcat, but that didn't work for me. Netcat wasn't installed on the firewall. As it turns out, and I don't know why this was so hard to find, SSH has netcat built in. So instead of doing something like this: … -
Geocoding: Turning text into numbers
One of my favorite libraries for doing geo in Python is GeoPY. It’s able to do one of the next tools we need in our toolbox, plus a few others. What is this new tool? Geocoding. Geocoding is the process … Continue reading → -
Good ol' SSH
I’ve recently started using a Mac as my primary computer. It’s been a fairly easy transition as most everything I work on is already *nix based and the majority of the software I use is cross-platform. One thing I did miss was PuTTY. Mostly because I could easily save sessions and invoke them with “putty -load whatever”. Meanwhile, invoking SSH manually in Terminal was a pain. Well, that turned out to be quite an easy fix. How is it that I never knew about ssh-config? Merely create a “~/.ssh/config” file and put in: 1 2 3 Host whatever HostName whatever.wherever.com User myuser Now you can just “ssh whatever” from a Terminal window. What a relief! Next, I used to make use of “plink” as a local proxy command in PuTTY to create a tunnel through a firewall for work. How do you do this with regular SSH? Well, Google returns lots of results on how to use the ProxyCommand ssh-config option along with netcat, but that didn’t work for me. Netcat wasn’t installed on the firewall. As it turns out, and I don’t know why this was so hard to find, SSH has netcat built in. So instead of doing … -
Using a jQuery plugin in Django admin and getting a “$().foo is not a function” or “Object ... has no method foo” error?
Are you using a jQuery plugin, for instance jQuery UI, to spice up the Django admin site? Then you might get either an error like “foo is not a function” (Firebug) or “Object ... has no method foo” (Chrome Developer Tools). Are you confused because foo should be defined in the plugin? Don’t worry, the solution is simple. Actually, the reason and solution are in the Django admin site documentation if you know where to look. The reason is this: Django’s jQuery is namespaced as django.jQuery This prevents collisions with other scripts or libraries. It also prevents you from blindly using code you find on the internet. ;-) Possible solutions are: Include your own copy of jQuery which does ‘pollute’ the global namespace. Make sure your plugin/code uses django.jQuery instead of just $ or jQuery. Create a jQuery (or $) variable yourself. As the documentation says, the benefit of the first option is that you can use a different (newer) version of jQuery, if you want or need to. The second option might mean that you’ll have to download the development version of the plugin, change the code, and minify it yourself. I found the third option as an answer … -
Pinax
Pinax. Und wieder mal was das ich glaube ich schon hatte. Aber aus aktuellem Grund nochmal auf den Radar gekommen und daher werde ich mir das etwas näher angucken. Sowas wie ein Bauchladen für Django-Projekte mit Fokus auf Social Networks und Community Sites. Klingt auf jeden Fall sehr interessant – ein bischen wirkt es wie Drupal mit Python und auf Django (also eher nicht fertige Sites sondern Bausteine und Framework zur Erstellung derselben). -
Basic poly/point spatial queries using the Django ORM
Now that we have a couple sources of information in our database, we’ll look at mashing up the data. If I need to determine all of the campgrounds available during a trip to Kansas, I can do that with the … Continue reading → -
Small open-source release: django-menu
Many moons ago on this blog I wrote about a simple menuing system for Django. For the sake of convenience, I've just packaged up that code (plus a few minor improvements) into a package named django-menu which is also available via PyPi with pip install django-menu. Basic documentation is included in the package and in the git repository. -
Small open-source release - django-menu
Many moons ago on this blog I wrote about a simple menuing system for Django. For the sake of convenience, I've just packaged up that code (plus a few minor improvements) into a package named django-menu which is also available via PyPi with pip install django-menu. Basic documentation is included in the package and in the git repository. Please log any issues or suggested improvements via the GitHub issue tracker! -
Small open-source release - django-menu
Many moons ago on this blog I wrote about a simple menuing system for Django. For the sake of convenience, I've just packaged up that code (plus a few minor improvements) into a package named django-menu which is also available via PyPi with pip install django-menu. Basic documentation is included … -
Getting the data in, part 2 – CSV and “manual” importing
Before we move on to querying and displaying, let’s look at how to get data into the database from “bare metal” – as nice as LayerMapping is not everything is in a shapefile, and using other formats has a few … Continue reading → -
Djangonauts and GeoDjango
Many thanks to Joe Jasinski and Eric van Zanten for their presentations on GeoDjango at November's Chicago Djangonauts meetup. Joe kicked off the evening with his presentation, Introduction to GeoDjango. The presentation was based on his recent blog post GeoDjango Quickstart. Joe has also provided his presentation slides. After ... -
Getting the data in – Shapefiles with LayerMapping
There’s a lot of fun geospatial data out there once you start looking, and the biggest format you’ll find (particularly when dealing with government sources) is the Shapefile. Shapefiles are a proprietary but documented standard created by ESRI, the giant of … Continue reading → -
Tumblr
Well, I finally took the plunge and switched to Tumblr. As much as I wanted to create my own blog using Django or some other Python project (like Hyde), I finally realized that what I really wanted to do was write posts. So hopefully this will be relatively painless and I can now focus on actual blogging rather than coding a blog. -
Extending Django Settings for the Real World
A basic Django installation keeps its global variables in a file called settings.py. This is perfect for simple deployment because it allows the developer to overwrite Django variables like INSTALLED_APPS or SESSION_ENGINE very easily. You simply update the variable like so: SESSION_ENGINE = 'django.contrib.sessions.backends.cache' From within the shell, you can see the result: ./manage.py shell >>> from django.conf import settings >>> settings.SESSION_ENGINE 'django.contrib.sessions.backends.cache' Many people have two environments in which they work, and therefore a typical settings.py file will have something like this at the end: try: from local_settings import * except ImportError: pass This overwrites variables from a file called local_settings.py, overriding any existing variables in the settings.py file. Try it. Add the import code above into your settings.py file and create a new file called local_settings.py in the same directory as the settings.py file and add this to it: SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db' Now, if you enter the shell like you did above and request settings.SESSION_ENGINE, you’ll get ‘django.contrib.sessions.backends.cache’. This is very handy because, in a typical situation, you can have a settings.py file which works for all your environments and then have a local_settings.py file for each environment that overrides the variable values. Problems with the Standard Settings … -
Code Month: Day one
Code Month: Day one -
It all begins: Geographic models
Before we can store geographic information about or query for an object we have to know what we’re storing or querying by. So what do we choose? If we’re storing the location of an object, a models.PointField is your best … Continue reading → -
Django Facebook user integration with whitelisting
It's recently become quite popular for web sites to abandon the tasks of user authentication and account management, and to instead shoulder off this burden to a third-party service. One of the big services available for this purpose is Facebook. You may have noticed "Sign in with Facebook" buttons appearing ever more frequently around the 'Web. The common workflow for Facebook user integration is: user is redirected to the Facebook login page (or is shown this page in a popup); user enters credentials; user is asked to authorise the sharing of Facebook account data with the non-Facebook source; a local account is automatically created for the user on the non-Facebook site; user is redirected to, and is automatically logged in to, the non-Facebook site. Also quite common is for the user's Facebook profile picture to be queried, and to be shown as the user's avatar on the non-Facebook site. This article demonstrates how to achieve this common workflow in Django, with some added sugary sweetness: maintaning a whitelist of Facebook user IDs in your local database, and only authenticating and auto-registering users who exist on this whitelist. -
Setting up Apache server for Django with mod_wsgi
Django is a very cool web development framework which comes with its own lightweight development server which is best for testing the application. But when it comes to deploying the application for the outer world, more efficient and secure web … Continue reading → -
The Installation
Please join me this month as we dive head first into building things with Python (and Django) emphasizing location information. I hope at the end of this you’re up to speed on building basic location-aware web apps and no longer … Continue reading → -
Django-ratelimit-backend ne réglera pas vos problèmes de foie, mais de rate oui…
Deuxième édition de la django app du mois précédent, encore une fois sur le fil, alors que les citrouilles continuent à ricaner dans leurs coins. Ce mois-ci c’est django-ratelimit-backend, une des multiples apps de monsieur Brutasse (qui ne doit jamais dormir pour publier autant de truc…) 1- Où on le trouve, comment on l’installe, tout ça quoi (et la doc) ? Deux possibilités pour le trouver, sur sa page github (on regrettera le choix de github et non bitbucket mais bon:) ) ou sur sa page pypi. Ce qui du coup vous permettra de l’installer de deux façon : un petit git clone bien de chez nous un simple : pip install django-ratelimit-backend La doc est dispo sur la page readthedocs du projet. Et elle est bien fournie. Une aide à l’install, un quickstart et une section pour expliquer comment modifier le critère de limitation et une référence complète du code. 2- Mais au fait, à quoi ça sert ? A empêcher les vilains méchants pas beau de crier ‘des logins ou un sort’ devant vos jolis sites webs Django. En clair, à ‘bannir’ pendant 5 minutes des IP qui auraient tentées de se logguer sur votre appli à de … -
Django Explorer - What's up?
Django Explorer - What's up? -
DIY supplies
Since moving to the country a year ago my weekends and evenings have turned into project time. I’m a cheapskate, so I’ve been buying and repairing lots of used tools and making a lot of my own parts. This means I’m constantly looking for some random specific bolt, or a piece of plastic some particular size, or something similarly specific and esoteric. So I starting maintaining a list of the places I go to when I need supplies. -
Blog Intro / November Attempt
Welcome (a little early) to November, a month where many technical authors around the internet will be attempting to write one blog post per day. I intend to join them – on something very interesting to me and useful for … Continue reading →