Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
To Django Con and beyond
My journey to Django Con Amsterdam and beyond -
How to install virtualenv on webfaction
How to install virtualenv on webfaction -
How to install virtualenv
Find out why and how to install virtualenv -
Added Haystack search with Whoosh to this site
Added Haystack search with Whoosh to this site -
Display Django and Python version numbers on your site
Display Django and Python version numbers in template -
Putting it all together: A sample, simple project, part 1
We’ve discussed all sorts of things this month, now it’s time to start putting them together more completely than snippet-for-this, snippet-for-that. I’m not going to inline command + output on everything but I am going to spell out all of the steps – if you have trouble, let me know in the comments. To accomplish this we’re going to build a simple web service I’ve snagged “isthatanearthquake.com” for. First order of business is creating the project. Because virtualenv and virtualenvwrapper rocks (`pip install virtualenv virtualenvwrapper`), I started with `mkvirtualenv isthatanearthquake`. My global virtualenv `postactivate` script includes the line `cd $VIRTUAL_ENV` which drops me in the env whenever I activate it. Next I created a `src` directory, created and cd’ed into `isthatanearthquake-git`, created `templates` and created requirements.txt with these contents: django==1.3.1 psycopg2==2.4.2 -e git+git://github.com/adamfast/django-quakes.git@4d9fcdb4978a28f35d1e32406a81f3b8b5d58845#egg=quakes pip install -r requirements.txt gets me Django, Postgres and the reusable app django-quakes (thanks Sean Bleier, who I’ve forked the library from for this example) installed in my virtualenv. Create the Django project with `python $VIRTUAL_ENV/lib/python2.?/site-packages/django/bin/django-admin.py startproject isthatanearthquake` (note you will need to specify your python version in this command) `add2virtualenv isthatanearthquake` will make the new project show up on your PYTHONPATH. Open isthatanearthquake/settings.py and `import os` … -
Adding CoffeeScript
With CoffeeScript becoming more and more popular it is time to start using it. This video is about how to get CoffeeScript added to your project so you can start developing with it.Watch Now... -
Adding CoffeeScript
With CoffeeScript becoming more and more popular it is time to start using it. This video is about how to get CoffeeScript added to your project so you can start developing with it.Watch Now... -
Custom Admin Filter Specification
Let's say we have a model Project with age groups as boolean fields: class Project(models.Model): # ... age_group_0_5 = models.BooleanField(u"From 0 to 5 years") age_group_6_12 = models.BooleanField(u"From 6 to 12 years") age_group_13_18 = models.BooleanField(u"From 13 to 18 years") age_group_19_27 = models.BooleanField(u"Fron 19 to 27 years") # ... In order to list them as one selection in the admin list filter, we need a specific filter specification. Let's create it in the admin.py: from django.contrib.admin.filterspecs import FilterSpecclass AgeChoicesFilterSpec(FilterSpec): def title(self): return u"Age group" def __init__(self, f, request, params, model, model_admin, field_path=None): super(AgeChoicesFilterSpec, self).__init__(f, request, params, model, model_admin, field_path=field_path) self.request = request def choices(self, cl): yield {'selected': not( self.request.GET.get('age_group_0_5', None) or self.request.GET.get('age_group_6_12', None) or self.request.GET.get('age_group_13_18', None) or self.request.GET.get('age_group_19_27', None) ), 'query_string': cl.get_query_string( {}, ['age_group_0_5', 'age_group_6_12', 'age_group_13_18', 'age_group_19_27']), 'display': u'All'} yield {'selected': self.request.GET.get('age_group_0_5', None) == 'True', 'query_string': cl.get_query_string( {'age_group_0_5': 'True'}, ['age_group_6_12', 'age_group_13_18', 'age_group_19_27']), 'display': u"From 0 to 5 years"} yield {'selected': self.request.GET.get('age_group_6_12', None) == 'True', 'query_string': cl.get_query_string( {'age_group_6_12': 'True'}, ['age_group_0_5', 'age_group_13_18', 'age_group_19_27']), 'display': u"From 6 to 12 years"} yield {'selected': self.request.GET.get('age_group_13_18', None) == 'True', 'query_string': cl.get_query_string( {'age_group_13_18': 'True'}, ['age_group_0_5', 'age_group_6_12', 'age_group_19_27']), 'display': u"From 13 to 18 years"} yield {'selected': self.request.GET.get('age_group_19_27', None) == 'True', 'query_string': cl.get_query_string( {'age_group_19_27': 'True'}, ['age_group_0_5', 'age_group_6_12', 'age_group_13_18']), 'display': u"From 19 … -
GDD - RSS Feeds
I've decided to start a new occassional series, called God Dammit, Django. If I say "God DAMMIT, Django!" more than three times in one coding session before solving my problem, that's a sign that I need to blog about the solution. Why do this? One of my regrets as I've ... -
Django permissions are untranslatable
-
Working with files in Django – Part 1
In this post what I mean by file is any content that is not dynamically generated. There are basically two types of files a web application deals with: Files that are hard coded in templates or in code. We will call them STATIC files. Files that are referenced in the code but only known in [...] -
Python os.stat times are OS specific …
A pitfall I faced while I was playing with PyTDDMon. It appeared that os.stat times return different type of values int and float depending on the OS. Fortunately this can be avoided with the help of stat_float_times. -
Finding Data: Often harder than using it
One of the hardest parts of doing geo projects is getting the data you need to do it in the first place. In the US at least there are mountains of data at the federal level, some at the state level and who knows what at the local level. There isn’t a single place I can go to for anything outside of census-type stuff. Which school for a given grade level would a child at this point attend? Maybe it’s published, maybe it’s not. Most cities or counties will have a GIS department. Some of them will be great, and helpful towards your goal as a developer. Others won’t. Our world of the tools and technologies are leapfrogging traditional methods. So here’s some of my favorite sources of different kinds of data, worth looking at for your next project. TIGER/LINE: Gigabytes of shapefiles of things the US Federal government collects. I tend to look here first if I need basic location data. SimpleGeo Places DB: SimpleGeo put a dataset of 21 million places (12ish million in the US) into the public domain last summer, and links to the file here. I have played with the data some and it’s pretty … -
Django Suite II: Configurando nuestro proyecto de manera correcta.
En esta entrada abordaremos un tema importante: la configuracióndel proyecto. Como dije en la entrada anterior, en configuraciones tampoco hay una manera definitiva de hacer las cosas ya que la flexibilidad de Django nos lo permite. Django usa archivos Python para guardar configuraciones, aprovecha la manera de trabajar del lenguaje para hacer archivos de configuración fáciles de leer, extender y utilizar dentro de nuestros proyectos. Normalmente al iniciar una aplicación creamos un proyecto en blanco con el comando startproject que nos crea una carpeta con los archivos necesarios para iniciar. Por defecto estas configuracionestienen ciertos valores de los cuales normalmente nos molestaremos en cambiar sólo algunas, como configuración de bases de datos, ubicación de archivos estáticos y servidor de correo. Acá algunos trucos para hacer estas configuraciones de manera dinámica y distribuibles para usarse en sistemas de control de versiones: Separación del archivo settings.py Este archivo contiene muchas veces datos sensibles que no pueden ser publicados o simplemente varían de una estación de trabajo a otra, por lo que conviene separarlo con un archivo extra que por convención lo llamamos"settings_local.py" acá deberán ir estas configuraciones: DATABASES ADMINS DEBUG TEMPLATE_DEBUG SECRET_KEY (si lo vas a hacer código libre y público) Claves … -
Django Suite II: Configurando nuestro proyecto de manera correcta.
En esta entrada abordaremos un tema importante la configuración del proyecto, a como dije en la entrada anterior en configuraciones tampoco hay una manera definitiva de hacer las cosas, ya que la flexibilidad de Django nos lo permite. Django usa … Continue reading → -
Google loves LFS
After just two weeks online, the LFS based summerhouse-shop reached for the search tearm "Bearcounty Gartenhaus" the first page at Google: Moreover there are already 119 pages indexed: In large part with nice titles, meaningful descriptions and the LFS typical flat and well formed URLs: -
First shop is online
The first online shop based on LFS is online: http://www.gartenhaus-bearcounty.de/ The summerhous shop is driven by Demmelhuber Holz und Raum Vertriebs GmbH, which runs already a german top 500 shop based on EasyShop: http://demmelhuber.net/shop Demmelhuber has very high requirements on its webshops and we are very pleased that they decided to take LFS after an intense evaluation phase. The LFS-Team works now very close with Demmelhuber Holz und Raum Vertriebs GmbH in order to optimize the shop continuously. We thank Demmelhuber for the confidence and wish good luck and lots of success with the new online shop! -
Another shop is online
Another shop based on LFS is online: http://www.swimmingpool-bearcounty.de/ The swimmingpool shop is driven by Demmelhuber Holz und Raum Vertriebs GmbH, which runs already a german top 500 shop based on EasyShop: http://demmelhuber.net/shop. Demmelhuber is already gone online with the first LFS based shop recently. The special thing on this shop is that we are using variants the first time in production. Check this example out. -
Second shop is online
The second online shop based on LFS is online: http://www.gartenmoebel-bearcounty.de/ The garten furniture shop is driven by Demmelhuber Holz und Raum Vertriebs GmbH, which runs already a german top 500 shop based on EasyShop: http://demmelhuber.net/shop. Demmelhuber is already gone online with the first LFS based shop recently. iqpluplus works now very closely with Demmelhuber Holz und Raum Vertriebs GmbH in order to optimize the three shops continuously. We thank Demmelhuber for the confidence and wish good luck and lots of success with the new online shop! We are also working on a further shop now, which will go online with a brand new design soon (2 - 4 weeks). Stay tuned! -
New Shop is online
Another shop based on LFS is online: http://www.terrassenueberdachung-bearcounty.de/ The terrace shop is driven by Demmelhuber Holz und Raum Vertriebs GmbH, which runs already a german top 500 shop based on EasyShop (http://demmelhuber.net/shop) - and serveral other shops based on LFS. This time the good people of Demmelhuber installed and customized the shop completely inpedendent, which hopefully proves that LFS is easy to use. We are working on several other shops. So stay tuned for more ... -
Released 0.6 beta 1
Update: We also have a public Jenkins instance for continues integration on shiningpanda After more of six months we are happy to announce that we have released LFS 0.6 beta 1. Kudos to Michael Thornhill (of http://www.maithu.com/) who did a lot of work. So what's new? Using Django 1.3 Added country dependent addresses Added pluggable price calculation Added supplier management Massively improved management interface Improved static file handling (Django's staticfiles) Improved properties management Removed SWFUpload (Flash) in favour of jquery.fileupload (Javascript) Using Python's locale to display currencies New contact form Migration Starting with this release we provide a migration command (lfs_migrate, based on South) to upgrade your existing LFS instances. Please refer to the documentation for further information. Further Information You can find more information and help on following places: Official page Documentation on PyPI Demo Releases on PyPI Source code on bitbucket.org Google Group lfsproject on Twitter IRC -
Reflexions
Reflexionant Aprofitant que avui és una jornada de reflexió me pareix que aprofitaré per repassar un poc l'anecdotaria personal d'aquestes darreres setmanes, a veure si en puc treure també algunes conclusions. No sé el que vull Donc així ens va venir una persona a veure'ns i d'entrada em va amollar aquesta frase. Bé, res a dir, això és bastant típic quan es comença un projecte. El client no sap massa bé què vol, i la meva feina sovint consisteix en anar fer preguntes, clarificant el que el client vol. Al final, després d'hores de conversa vaig definint el que podria ser el projecte: gran, molt gran. El client resulta que nos sap què vol, però sap que ho vol tot! Paralant parlant ens diu que ja té un altre pressupost. Diu que ens ho enviarà per a que li poguem pressupostar el mateix. Fantàstic, al manco hi ha un punt de partida. Al dia següent em pos a repassar les notes i començar a fer el pressupost. Quan m'arriba l'e-mail del client jo ja duc com a 8 fulles del pressupost, explicant què tindrà el programa d'acord amb les especificacions del client. El pressupost que reb em deixa de pedra. … -
Scrubbing your Django database
This is the second in a series of posts, focusing on issues around open sourcing your Django site and data privacy in Django. You’ll end up with production data in your Django database and that will likely contain different kinds of data such as: configuration data, required basic data (categories for example), collected data and [...] -
Scrubbing your Django database
This is the second in a series of posts, focusing on issues around open sourcing your Django site and data privacy in Django. You’ll end up with production data in your Django database and that will likely contain different kinds of data such as: configuration data, required basic data (categories for example), collected data and personal user data. There’s a couple of reasons for taking that production data and copying it off your production servers: for developers and contributors you want a sample copy of the app with some key data in. for testing or staging servers, you might want to copy down the database from the production server so you can test certain scenarios or load. Extracting parts of your database For the first case, it’s nice to prepare a minimal copy of the database that contains key data. For example, for those wanting to develop or contribute to addons.mozilla.org we have Landfill by Wil Clouser. Django comes with a nice facility for loading data, fixture dumping and loading. This can be used to pull data out of your database and then reload it. However the built in Django dumpdata dumps all the records for your model (depending upon …