Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
How I Write Django Reusable Apps
Over the past year I have written quite a number of reusable apps or have made significant contributions to previously existing ones (most if not all of these are under Eldarion or Pinax organizations on GitHub). A sort of a pattern has developed as I have learned little bits from trial and error so I thought I'd capture them in a single post as they might be useful for other app authors. In summary they are: Start with a Real Project Provide Signals Properly Package and Document Your App Maintain a CHANGELOG Provide injection points in Views Start with a Real Project I find it very difficult to develop good useful apps with features that are meaningful and work well, when built in the abstract. I also need a real project (whether an active project under development or a sample project doing real work for the purpose of proving out said app). All of the apps I have written to date started in a project being built for real. I got it working in the project, abstracted away domain specific and project specific bits and replaced the in project code with a requirements listing for the packaged version of the … -
How I Write Django Reusable Apps
Over the past year I have written quite a number of reusable apps or have made significant contributions to previously existing ones (most if not all of these are under Eldarion or Pinax organizations on GitHub). A sort of a pattern has developed as I have learned little bits from trial and error so I thought I'd capture them in a single post as they might be useful for other app authors. In summary they are: Start with a Real Project Provide Signals Properly Package and Document Your App Maintain a CHANGELOG Provide injection points in Views Start with a Real Project I find it very difficult to develop good useful apps with features that are meaningful and work well, when built in the abstract. I also need a real project (whether an active project under development or a sample project doing real work for the purpose of proving out said app). All of the apps I have written to date started in a project being built for real. I got it working in the project, abstracted away domain specific and project specific bits and replaced the in project code with a requirements listing for the packaged version of the … -
Installing DjangoCMS on Heroku in 13 easy steps
Do you want to use Django-cms on Heroku but don't know where to start? All you need to do is follow these 13 easy steps, and they will get you on your way. Create a place to store your project $ mkdir -p ~/projects Go into the projects directory $ cd ~/projects Clone git repo from github, requires git client. $ git clone git://github.com/kencochrane/django-cms-heroku.git Go into the new project directory $ cd django-cms-heroku Creating the virtualenv (using virtualenvwrapper, virtualenv, and pip) $ mkvirtualenv --no-site-packages --distribute django-cms-heroku Sign-Up for a Heroku account. https://api.heroku.com/signup Install the Heroku client. http://devcenter.heroku.com/articles/quickstart The first time you use the Heroku client you will need to login using the same information you used when you signed up. Follow the prompts, and it will finish your install. $ heroku login Create your heroku application $ heroku create --stack cedar Push your code into heroku $ git push heroku master Sync your database and create your admin account. $ heroku run python mycms/manage.py syncdb --all Run your database migrations. $ heroku run python mycms/manage.py migrate --fake Open application in your browser and start using djangoCMS on heroku. $ heroku open Once you get comfortable with how things work, you … -
Installing DjangoCMS on dotCloud in 12 easy steps
Do you want to use Django-cms on dotcloud but don't know where to start? All you need to do is follow these 12 easy steps, they will get you on your way. Create a place to store your project $ mkdir -p ~/projects Go into the projects directory $ cd ~/projects Clone git repo from github, requires git client. $ git clone git://github.com/kencochrane/django-cms-dotcloud.git Go into the new project directory $ cd django-cms-dotcloud Creating the virtualenv (using virtualenvwrapper, virtualenv, and pip) $ mkvirtualenv --no-site-packages --distribute django-cms-dotcloud Installing the dotCloud client http://docs.dotcloud.com/firststeps/install/ (here are the steps for Linux and Mac OSX) $ sudo pip install -U dotcloud Sign up for a dotcloud account https://www.dotcloud.com/accounts/register/ if you haven't already. The first time you use the dotcloud account you will need to add your api key. So type dotcloud and follow the steps. You can find your API key at http://www.dotcloud.com/account/settings $ dotcloud Create your dotcloud application $ dotcloud create mycmsapp Push your code into dotcloud $ dotcloud push mycmsapp . Find out your application url. $ dotcloud url mycmsapp Open url in your browser and start using djangoCMS on dotcloud. Optional: If you don't like the URL they gave you, you can use … -
Release 0.6.3
We just released LFS 0.6.3. This is a yet another bugfix release. Changes Fixed update of prices if a configurable product is for sale. Fixed calculation of property prices for configurable products. Fixed saving of property data (added missing csrf token). Fixed removing products / properties from a group. Fixed filtering for float field steps. News: We have setup a GitHub mirror of LFS. The docs are running on our own domain now (still hosted on RTD) and have a new layout: http://docs.getlfs.com/ Information You can find more information and help on following locations: Documentation on PyPI Demo Releases on PyPI Source code on bitbucket.org and github. Google Group lfsproject on Twitter IRC -
Flask-Jasmine: Execute Jasmine tests within Flask
Just finished Flask-Jasmine extension to execute beautiful Behavior Driven tests for Jasmine in JavaScript.Such extensions already exists for Django and for Rails. Now it's available for Flask too.Install with pip:pip install Flask-Jasmine Detailed instruction about configuration and usage -
Using New Relic with supervisord and gunicorn
New Relic recently added support for python to their awesome web application performance tool, and I have been playing with it on a number of projects. Installing and configuring new relic is pretty well covered in their own documentation, so there is no reason for me to repeat that here. One thing that isn't covered in the documentation is how to use new relic if you are using supervisord to control your gunicorn processes, and I'll take this time right now to show you what I did. Setting up new relic with supervisord and gunicorn is pretty easy. All that you need to do, is change your supervisor.conf file and then update your supevisor config, and you are good to go. Here is the supervisor.conf file for my awesome app, before I installed new relic. Note: These are not my real conf files, they have been changed to protect the guilty, so please excuse any typos. [program:awesome_app] directory=/opt/apps/awesome_home/awesome_app/ command=/opt/apps/awesome_home/bin/python2.6 /opt/apps/awesome_home/bin/gunicorn_django -c /opt/apps/awesome_home/awesome_app/conf/gunicorn.conf user=aweman autostart=true autorestart=true environment=HOME='/opt/apps/awesome_home/awesome_app/',DJANGO_SETTINGS_MODULE='settings' After I installed new relic. All you need to do is add the 'newrelic-admin run-program' command before the 'gunicorn_django' command and add an ENV variable called NEW_RELIC_CONFIG_FILE that is pointing to your newrelic.ini file. … -
Deferred foreign keys with django-dfk
django-dfk is a project that I developed for a recent project to allow foreign keys to be declared on models without an explicit target ('dfk' stands for 'deferred foreign key'). It provides an API to 'point' these foreign keys to a concrete target at a later date, and also allows you to forcefully 'repoint' foreign keys that have already been set up. This last facility should be used with caution - it's essentially akin to monkey-patching. You can use GenericForeignKeys for this, and these are slightly more flexible in that each model instance foreign key may point to a different model. However, there is a performance cost associated with them, and joining can be problematic. (The project actually rarely uses django-dfk directly - instead, it uses it as a basis for abstract foreign keys, which have a greater awareness of the application environment - however, that's a topic for another day.) Before we go much further though - rather than using this package, a better long-term investment would be to look at the app-loading branch that Arthur Koziel and Jannis Leidel have been working on - testing it, and helping them to get it into a state to be merged … -
Deferred foreign keys with django-dfk
django-dfk is a project that I developed for a recent project to allow foreign keys to be declared on models without an explicit target ('dfk' stands for 'deferred foreign key'). It provides an API to 'point' these foreign keys to a concrete target at a later date, and also allows you to forcefully 'repoint' foreign keys that have already been set up. This last facility should be used with caution - it's essentially akin to monkey-patching. You can use GenericForeignKeys for this, and these are slightly more flexible in that each model instance foreign key may point to a different model. However, there is a performance cost associated with them, and joining can be problematic. (The project actually rarely uses django-dfk directly - instead, it uses it as a basis for abstract foreign keys, which have a greater awareness of the application environment - however, that's a topic for another day.) Before we go much further though - rather than using this package, a better long-term investment would be to look at the app-loading branch that Arthur Koziel and Jannis Leidel have been working on - testing it, and helping them to get it into a state to be merged … -
Deferred foreign keys with django-dfk
django-dfk is a project that I developed for a recent project to allow foreign keys to be declared on models without an explicit target ('dfk' stands for 'deferred foreign key'). It provides an API to 'point' these foreign keys to a concrete target at a later date, and also allows you to forcefully 'repoint' foreign keys that have already been set up. This last facility should be used with caution - it's essentially akin to monkey-patching. You can use GenericForeignKeys for this, and these are slightly more flexible in that each model instance foreign key may point to a different model. However, there is a performance cost associated with them, and joining can be problematic. (The project actually rarely uses django-dfk directly - instead, it uses it as a basis for abstract foreign keys, which have a greater awareness of the application environment - however, that's a topic for another day.) Before we go much further though - rather than using this package, a better long-term investment would be to look at the app-loading branch that Arthur Koziel and Jannis Leidel have been working on - testing it, and helping them to get it into a state to be merged … -
Sewing Success with Fabric
I wanted to share a quick practical example of how Fabric, can make your development life easier. If you're unfamiliar with Fabric I recommend checking out its tutorial which describes Fabric thusly; Fabric is a Python (2.5 or higher) library and command-line tool for streamliningthe use of ... -
A year looking back, and looking forward
I'm not big into resolutions. I've only had it work one year, and that was because my resolution was to go on a cruise. That's not exactly the most strenuous goal to work towards, is it? I still like the end of the year, though, for a chance to look ... -
Realtime Postfix stats aggregator
-
django-celery, eventlet and debugging blocking
-
Class-based views in Django 1.3
Django class-based views Introduction Django 1.3 added class-based views, but neglected to provide documentation to explain what they were or how to use them. So here's a basic introduction. Example of a very basic class-based view Let's start with an example of a very basic class-based view. urls.py: ... url(r'^/$', MyViewClass.as_view(), name='myview'), ... views.py: from ... -
Class-based views in Django 1.3
Django class-based views Introduction Django 1.3 added class-based views, but neglected to provide documentation to explain what they were or how to use them. So here's a basic introduction. Example of a very basic class-based view Let's start with an example of a very basic class-based view. urls.py: ... url(r'^/$', MyViewClass.as_view(), name='myview'), ... views.py: from ... -
Class-based views in Django 1.3
Django class-based views Introduction Django 1.3 added class-based views, but neglected to provide documentation to explain what they were or how to use them. So here's a basic introduction. Example of a very basic class-based view Let's start with an example of a very basic class-based view. urls.py: ... url(r'^/$', MyViewClass.as_view(), name='myview'), ... views.py: from ... -
OpenBlock Geocoder, Part 3: External Geocoders
The OpenBlock geocoder is powerful and robust. It uses PostGIS for spacial queries, can extract addresses from bodies of text, and can understand block and intersection notation. We've run into a few issues with it, however, including a low geocoding success rate. This is a tough problem to solve and depends on a lot of ... -
OpenBlock Geocoder, Part 3: External Geocoders
The OpenBlock geocoder is powerful and robust. It uses PostGIS for spacial queries, can extract addresses from bodies of text, and can understand block and intersection notation. We've run into a few issues with it, however, including a low geocoding success rate. This is a tough problem to solve and depends on a lot of ... -
OpenBlock Geocoder, Part 3: External Geocoders
The OpenBlock geocoder is powerful and robust. It uses PostGIS for spacial queries, can extract addresses from bodies of text, and can understand block and intersection notation. We've run into a few issues with it, however, including a low geocoding success rate. This is a tough problem to solve and depends on a lot of ... -
Quick Optional Model Fields Trick
This is just something I do now. It’s DRY, saves a few keystrokes, helps stay under pep8’s 79 character limit, and improves readability in my opinion. http://gist.github.com/1526444 -
Django Caching in the Real World: Part 1
When you develop a sizable content heavy web site you quickly learn, hopefully not the hard way, that caching is a very important piece of your infrastructure. The database servers are the typical bottleneck in high volume website. In this series, we’ll explore the a caching strategy we recently implemented. -
Resum del 2011
Ara que ja estam a punt d'acabar el 2011 faré el que toca fer per aquestes dates no és més que fer un resum de l'any que acaba i fer un poc d'avançament del que esper en el 2012. Com bé sabeu, darrerament per mi parlar d'informàtica i feina és parlar d'APSL, el projecte que iniciàrem fa uns anys amb un grapat de socis, parlar de Python, de Django i de GNU-Linux. APSL El febrer de 2012 ja farà tres any de la posada en marxa del projecte APSL, que per qui no ho sap és l'acrònim d'Advanced Programming Solutions SL. El nom el pensarem a un dinar entre en Bernat, en Xus i jo mateix, a partir d'un domini de quatre lletres que vaig poder comprar gairebé de casualitat. Primer va ser el domini i després va ser el nom. Ara no record ben bé qui va proposar la versió final, però record clarament que en parlàvem amb Xus. Sigui com sigui enguany ha suposat passar dels 2 membre amb que iniciàrem el 2010 a passar a quatre i tenir que canviar d'oficina, passant de la incubadora del Parc Bit a un despatx compartit a l'edifici NTIC del mateix … -
Release 0.6.2
We just released LFS 0.6.2. This is a bugfix release. Following bugs have been fixed: fixed issue with utf-8 support for MySQL; issue #126 fixed product filtering; issue #124 LFS goes Github We have setup a Github mirror of LFS. So if you feel more comfortable with Github then check it out. Information You can find more information and help on following locations: Official page Documentation on PyPI Demo Releases on PyPI Source code on bitbucket.org and github. Google Group lfsproject on Twitter IRC -
My Django 1.4 Project Template
Django supports custom project templates as of 1.4. This is a feature i’ve been dreaming for and since have created what I consider - and hope - is an improved project template for most. https://github.com/amccloud/django-project-skel/ Changes and additions Global templates, static, and fixtures directory. Collects static and media into public/{static,media} respectively. Django admin activated by default. Django timezone setting changed to UTC for sanity. HTML 5 base template with simple 404 and 500 error templates. Discourages storing credentials and secrets in the repository. Encourages the use of local_settings.py and accompanying __local_settings.py template. Encourages the use of virtualenv and virtualenvwrapper. Encourages the use of pip and requirements.txt. Encourages the use of git. Includes a .gitignore for the usual junk. Automatically builds a README with installation notes. How to use django-admin.py startproject --template https://github.com/amccloud/django-project-skel/zipball/master --extension py,md yourprojectname Contribute on GitHub