Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
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 → -
Generar arxius xls amb Python III
En aquesta tercera entrega veurem com podem fer que des de la nostra aplicació Django es puguin generar i servir els arxius que hem generat amb la llibreria xlwt. La mecànica és la mateixa que la que hi ha als tutorials de Django que mostren com servir un arxiu csv o un pdf, així que per a que serveixi d'alguna cosa més us mostraré como ho feim utilitzant les generic class views incorporades a Django 1.3. El que volem fer és poder mostrar els resultats per pantalla i després poder afegir un link que ens retorni les dades que tenim en pantalla en forma d'arixu descarregable. ListView Per el nostre propòsit farem servir la classe ListView que es troba a django.views.generic La utilització més típica d'aquesta classes implica sobreescriure el mètode get_query_set de tal manera que ens retorni les dades que mostrarem a la plantilla, i, com no, indicar-li el nom de la plantilla a la qual s'han de mostrar els resultats. El codi seria quelcom semblant a això per la part de views.py class TestView(ListView): """Classe de proves per l'article""" template_name='tests/user_list.html' def get_queryset(self): """Listam tots els usuaris que no són superusuaris""" return User.objects.filter(is_superuser=False) a l'arxiu urls.py crearem la url … -
I'm available for consulting
I’m not really a freelancer for life, but I enjoy rare occasions of small “outside” gigs. I need some money boost right now, for both UploadCare (which is doing really, really fine!) and some personal problems1. So if you’re looking for someone to work with you for a couple of hours, weeks or months, I’d be happy to come forward. I’m pretty good with some programming stuff. Please write me to: v.golev@gmail.com. What I can do I’ve got my share of experience with Django. I know most of its dark corners and stumbled upon some of its crankeries. I’m writing a lot about it in my blog. I have successfully contributed a couple of lines of code into its ORM. I have teached my co-workers to use it and I have some experience debugging weird problems with South. I’ve secured the third place at DjangoDash. I’m good with Python, too. I understand metaclasses, really. And other stuff. I’ve used some spooky libraries for it, like eventlet and nltk. I’m okay with JavaScript, though not really an expert. Hey, for some reason I’ve read a lot about ECMAScript standard and know some useless weird trivia about it. I know how to … -
In a month!?
In a month!? -
Django Without the Web
One of the things I like best about Django is how easy its ORM makes it to work with databases. Too bad Django is only for web applications. Sure, you could deploy a Django app and then make use of it from a non-web application using a REST API, but that would be too awkward.But ... -
Django Without the Web
One of the things I like best about Django is how easy its ORM makes it to work with databases. Too bad Django is only for web applications. Sure, you could deploy a Django app and then make use of it from a non-web application using a REST API, but that would be too awkward.But ... -
Django Without the Web
One of the things I like best about Django is how easy its ORM makes it to work with databases. Too bad Django is only for web applications. Sure, you could deploy a Django app and then make use of it from a non-web application using a REST API, but that would be too awkward.But ... -
Drop-in celery AbortableTask replacement
If you need to report progress updates from the tasks (or you call update_state in the task) you cannot use the bundled AbortableTask from celery.contrib.abortable because it relies on status updates too. That means you’ll get race conditions if you do that. You can use revokes for aborting tasks but they don’t give you enough control and it’s not guaranteed that your tasks will stop gracefully (or stop at all). Revokes can raise SoftTimeLimitExceeded if enabled (via TERM signal) however it might be tricky to perform cleanup – if you call C extension the exception will get delayed till the call returns. See the signal module docs for what happens when you raise an exception from a signal handler (that’s what celery does). Given this, an alternative is to use redis to store the aborted task ids in a redis set. If you use the redis broker you can use this drop-in replacement: from contextlib import contextmanager import celery from celery.task.base import Task from celery.result import AsyncResult from django.conf import settings assert settings.BROKER_TRANSPORT == 'redis', "AbortableTask can only work with a 'redis' BROKER_TRANSPORT" REDIS_KEY = getattr(settings, 'ABORTABLE_REDIS_KEY', 'task-aborts') @contextmanager def client_from_pool(): connection = celery.current_app.pool.acquire() try: yield connection.default_channel.client finally: connection.release() class … -
Drop-in celery AbortableTask replacement
If you need to report progress updates from the tasks (or you call update_state in the task) you cannot use the bundled AbortableTask from celery.contrib.abortable because it relies on status updates too. That means you'll get race conditions if you do that. You can use revokes for aborting tasks but they don't give you enough control and it's not guaranteed that your tasks will stop gracefully (or stop at all). Revokes can raise SoftTimeLimitExceeded if enabled (via TERM signal) however it might be tricky to perform cleanup - if you call C extension the exception will get delayed till the call returns. See the signal module docs for what happens when you raise an exception from a signal handler (that's what celery does). Given this, an alternative is to use redis to store the aborted task ids in a redis set. If you use the redis broker you can use this drop-in replacement: from contextlib import contextmanager import celery from celery.task.base import Task from celery.result import AsyncResult from django.conf import settings assert settings.BROKER_TRANSPORT == 'redis', "AbortableTask can only work with a 'redis' BROKER_TRANSPORT" REDIS_KEY = getattr(settings, 'ABORTABLE_REDIS_KEY', 'task-aborts') @contextmanager def client_from_pool(): connection = celery.current_app.pool.acquire() try: yield connection.default_channel.client finally: connection.release() class … -
Drop-in celery AbortableTask replacement
If you need to report progress updates from the tasks (or you call update_state in the task) you cannot use the bundled AbortableTask from celery.contrib.abortable because it relies on status updates too. That means you'll get race conditions if you do that. You can use revokes for aborting tasks but they don't give you enough control and it's not guaranteed that your tasks will stop gracefully (or stop at all). Revokes can raise SoftTimeLimitExceeded if enabled (via TERM signal) however it might be tricky to perform cleanup - if you call C extension the exception will get delayed till the call returns. See the signal module docs for what happens when you raise an exception from a signal handler (that's what celery does). Given this, an alternative is to use redis to store the aborted task ids in a redis set. If you use the redis broker you can use this drop-in replacement: from contextlib import contextmanager import celery from celery.task.base import Task from celery.result import AsyncResult from django.conf import settings assert settings.BROKER_TRANSPORT == 'redis', "AbortableTask can only work with a 'redis' BROKER_TRANSPORT" REDIS_KEY = getattr(settings, 'ABORTABLE_REDIS_KEY', 'task-aborts') @contextmanager def client_from_pool(): connection = celery.current_app.pool.acquire() try: yield connection.default_channel.client finally: connection.release() class …