Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Scary monsters and feature-creep
Scary monsters and feature-creep -
Einladung zur Django-UserGroup Hamburg am 11. Januar
Das nächste Treffen der Django-UserGroup Hamburg findet am Mittwoch, den 11.01.2012 um 19:30 statt. Wie bei den letzten Malen treffen wir uns wieder in den Räumen der CoreMedia AG in der Ludwig-Erhard-Straße 18 in 20459 Hamburg (Anfahrtsbeschreibung auf Google Maps). Bitte am Eingang bei CoreMedia AG klingeln, in den 3. Stock fahren und oben am Empfang nach der Django-UserGroup fragen. Da wir in den Räumlichkeiten einen Beamer zur Verfügung haben hat jeder Teilnehmer die Möglichkeit einen kurzen Vortrag (Format: Lightning Talks oder etwas länger) zu halten. Neben Projektvorstellungen werden dieses mal sicher auch die Neuerungen in Django 1.4 ein Thema sein. Die meisten Vorträge ergeben sich erfahrungsgemäß vor Ort. Als kleine Besonderheit wird bei diesem Treffen unter allen Teilnehmern eine Lizenz für PyCharm verlost, die uns der Hersteller JetBrains zur Verfügung stellt. Eingeladen ist wie immer jeder der Interesse hat sich mit anderen Djangonauten auszutauschen. Eine Anmeldung ist nicht erforderlich, aber hilfreich für die Planung: Doodle Kaldender. Weitere Informationen über die UserGroup gibt auf unserer Webseite www.dughh.de. -
Django Site Login Script
Just having a play around with a Python script that will login to a standard Django login form. I thought I’d share it as it’s quite interesting and I’m sure someone might find a use for it. It uses the standard Python modules urllib2, urllib and cookielib. It also requires BeautifulSoup for getting the generated CSRF [...] -
DjangoRedmineAdmin 1.0 released
I recently needed (again) to ‘browse’ a redmine database, and I used my DjangoRedmineAdmin application to do so. I took this opportunity to update the code and doing some more tests/fixes. As a result I decided to tag this as 1.0. The main modifications are: updated to comply with current redmine version (1.2.1 and 1.3.0) [...] -
Timing AMO user experience
There are lots of ways to measure the performance of a site. On addons.mozilla.org we measure a few of them: how long it takes to render pages, the cache performance and responsiveness for content delivery networks globally. But with the advent of the navigation timing API in Firefox 7 we’ve been able to add the [...] -
Timing AMO user experience
There are lots of ways to measure the performance of a site. On addons.mozilla.org we measure a few of them: how long it takes to render pages, the cache performance and responsiveness for content delivery networks globally. But with the advent of the navigation timing API in Firefox 7 we’ve been able to add the most important measurement of all – the actual performance in the browser. Along with a few other Mozilla sites, we’ve been using pystatsd and Graphite for a while. This produces useful graphs of the site health and performance. For example, this graph plots HTTP responses we serve out from Python (this is not the amount of traffic to our site which is much larger). To facilitate using the timing API we wrote a module between statsd and Django called django-statsd that, amongst other things, provides a way to interface between the browser and Python backend. The library has support for boomerang, a great front end timing library. I quickly wrote a much simpler service called stick, which sends a small subset of timings that we want. Using stick is straightforward – once you’ve setup your Python backed and included your JavaScript, you call it in … -
Extending User Model in Django
When building nearly every application in Django there comes a time where you want to associate more information with a user then just the built in ones. Django lets you as the programmer control how and where you want to handle this information. There are several ways to do this, and there is no absolute right or wrong way. This is just one way to manage extra user data and we find it very easy to use and manage. First we create a user profile model (Like to create a separate ”accounts” app to house this data). from django.contrib.auth.models import User from django.db.models.signals import post_save class UserProfile(models.Model): user = models.OneToOneField(User) #other fields here def __str__(self): return "%s's profile" % self.user def create_user_profile(sender, instance, created, **kwargs): if created: profile, created = UserProfile.objects.get_or_create(user=instance) post_save.connect(create_user_profile, sender=User) User.profile = property(lambda u: u.get_profile() ) As you can see above is a normal model with a foreign key to the Django User model. Then add any other fields you would want to store for a user: date of birth, website, favorate color, or whatever. Then we are going to tie a signal to the creation of users. In this case we use the django post_save signal … -
The Django gunicorn fabfile project
Since I read about Green Unicorn, better known as gunicorn, a Python WSGI HTTP server that goes along very well with Django, I knew I had to try it, and trying it I did. And I liked it. There were many steps to make a server work but overall it was cleaner than other approaches, including the Django deployment using Nginx, Apache and mod_wsgi that I described long time ago. And many reports indicate that a Django setup with gunicorn performs better than one using Apache. But when you have to setup many servers with the same configuration, the process gets boring and repetitive, and when you're bored you make mistakes. This is the perfect scenario for automating with Python and a Fabric script. I wanted the initial version of my fabfile to do the following: Start with a clean install of Ubuntu 11.10, just with an openssh-server running. Install all the Ubuntu packages needed for running a basic Django site, these include Nginx, virtualenv, some Python development tools, and PostgreSQL. Create virtual environments and manage them with virtualenvwrapper. Install a few Python packages in the virtual environments: Django, gunicorn, iptyhon, psycopg2, to name a few. Create the configuration files … -
Using Signals in your Django App
Yesterday, I posted a fairly popular post (for my blog anyway) dealing with how I write reusable Django apps. There were a couple of comments on Hacker News asking for some more details about some of thing suggestions mentioned in my post. Therefore, I'd like to start by digging into the use of signals to provide better site level integration. What is a signal anyway? A signal is defined by the Django documentation as: “Django includes a “signal dispatcher” which helps allow decoupled applications get notified when actions occur elsewhere in the framework. In a nutshell, signals allow certain senders to notify a set of receivers that some action has taken place.” A good example to highlight this is a recent upgrade I made to biblion which is the blog app that I use to drive this site. After my previous article was getting hammered from being on page 1 of HackerNews for an extended period of time, I noticed the page response times were starting to suffer. I took a more careful look at the detail view serving up the page and discovered it was calling post.inc_views() which would be making an update to a count on the row … -
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 ...