Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Initial Data Using South Migrations
Usually when starting a new project with commonly used apps, you will need some default data for the database, for example, default categories. Django provides fixtures for that. A fixture is a collection of data that Django knows how to import into a database. They say: If you create a fixture named initial_data.[xml/yaml/json], that fixture will be loaded every time you run syncdb. There is one problem with this approach. It is very likely that you will need to run syncdb in the future when adding new apps (without south migrations). In such cases the modified data will be overwritten with the initial data from fixtures. But there is a solution for that problem. You need to name your fixtures differently and then import them by south migrations. If you don't use south, you should start doing that, because it is a very handy way to modify database schema and data automatically. :) So this is how you can prepare south migration with the default fixture: 1. Create a fixture from existing models. python manage.py dumpdata --format=json --indent=4 myapp.Category > /path/to/myapp/fixtures/myapp_categories.json 2. Create data migration python manage.py datamigration myapp load_default_data 3. Edit data migration class Migration(DataMigration): def forwards(self, orm): from … -
We need more PyCon US 2013 submissions!
The PyCon US 2013 call for papers (CFP) ends tomorrow, September 28th, 2012. We need more talk and tutorial submissions. Talks are 30 or 45 minute efforts in front of the PyCon audience and are recorded for posterity. Tutorials are three hours long and are given to attendees who have paid an additional fee in order to slurp in knowledge from the masters. On the 3 hour tutorial side of things, we especially need more Intro to Python level efforts. That means getting beginners up to speed on basic Python techniques, so they can then exploit the other tutorials, conference, and sprints to their full advantage. Now onto some questions... 1. I would like to give a tutorial but it's so much work to put together 3 hours of quality content. The organizers of PyCon recognize that putting together a quality tutorial is an amazing amount of work. Which is why tutorial presenters are compensated for their effort. 2. What is the most likely length talk to be accepted? 30 minutes or 45 minutes? The vast majority of PyCon sessions are 30 minutes long, so 45 minute slots are rare and valuable commodities. So if your talk needs to be … -
Project Mwana featured in the BBC
Caktus has had the opportunity to work on the infrastructure of RapidSMS, an application framework that allows data collection and logistics coordination using mobile phone text messages for communication. The BBC World News recently posted an article, "RapidSMS: Saving a life in 160 characters" detailing the effects of RapidSMS technology is having on HIV/AIDS treatment in the developing world. The article focuses on work being done to combat the HIV/AIDS epidemic in Malawi where there is one of the highest rates of infection in the world. The statistics are sobering. More than 11% of Malawi's adults are living with HIV and around 120,000 children are thought to have the disease. [. . .] Annually, the United Nations estimates that 25% of new infections in the country are caused by mother-to-child transmission of the virus. That means it's absolutely critical that infants in Malawi get tested for HIV as soon as possible in the weeks following birth, and if they test positive, that treatment begins immediately. One of the main programs that has dramatically transformed the landscape of reporting test results is Project Mwana. Mwana, which means “baby” or “child” in Swahili, focuses on reducing the mother-to-child infection rate by using … -
Getting an IP Address in Django behind an Nginx Proxy
How to get the client IP address in Django when running Django behind an Nginx reverse proxy server. -
Django project file structure
As I promised in Automated deployment with Ubuntu, Fabric and Django I will use this post to explain the file structure that I use for my Django projects and what I benefit from it. So here is my project directory tree. The structure ~/workspace/<project_name>/ |-- bin |-- include |-- lib |-- local |-- src |-- .git |-- .gitignore |-- required_packages.txt |-- media |-- static |-- <project_name> | |-- <project_name> | | |-- __init__.py | | |-- settings | | | |-- __init__.py | | | |-- <environment_type>.py | | | |-- local.py | | |-- templates | | |-- urls.py | | |-- views.py | |-- manage.py | |-- wsgi.py |-- <project_name>.development.nginx.local.conf |-- <project_name>.< environment_type>.nginx.uwsgi.conf |-- <project_name>.< environment_type>.uwsgi.conf Explanation At the top I have a directory named as the project and virtual environment inside of it. The benefit from it is complete isolation of the project from the surrounding projects and python packages installed at OS level and ability to install packages without administrator permissions. It also provides an easy way to transfer the project from one system to another using a requirements file. The src folder is where I keep everything that is going to enter the version control … -
SSL behind an Nginx Reverse Proxy in Django 1.4
I recently upgraded one of my e-commerce websites to Django 1.4 and was very pleased to find the new SECURE_PROXY_SSL_HEADER setting. -
Demo live sites for 3 django apps
In the documentation of django-comments-xtd, django-inline-media and django-dress-blog I explain how to install the demo site of each application. However, sometimes it's useful to see the demo up and running before putting our hands on the code. With that intention I have set up demo sites for the aforementioned django apps. In order to see how they are integrated with the admin interface the three demos allow admin access too. You can see the already existing model instances, modify them and add new instances. Just keep in mind that the database is initialized every 30 minutes. The user and password are **admin**, **admin**. ##### Demos for django-comments-xtd Django-comments-xtd comes with two demos. The first live demo consist of just an app with one model, Article, whose instances accept comments. Simplicity helps to understand the basics. The second live demo allows site visitors to add comments to instances of various models. The intention is to show that it's possible to list comments sent to instances of different models presenting them as a feed. Two templatetags, `get_last_xtdcomment` and `render_last_xtdcomments`, offers such functionality, that reveals to be very useful in sites where traffic comes from user comments. The two demos for django-comments-xtd are: … -
Demo live sites for 3 django apps
In the documentation of django-comments-xtd, django-inline-media and django-dress-blog I explain how to install the demo site of each application. However, sometimes it's useful to see the demo up and running before putting our hands on the code. With that intention I have set up demo sites for the aforementioned django apps. In order to see how they are integrated with the admin interface the three demos allow admin access too. You can see the already existing model instances, modify them and add new instances. Just keep in mind that the database is initialized every 30 minutes. The user and password are **admin**, **admin**. ##### Demos for django-comments-xtd Django-comments-xtd comes with two demos. The first live demo consist of just an app with one model, Article, whose instances accept comments. Simplicity helps to understand the basics. The second live demo allows site visitors to add comments to instances of various models. The intention is to show that it's possible to list comments sent to instances of different models presenting them as a feed. Two templatetags, `get_last_xtdcomment` and `render_last_xtdcomments`, offers such functionality, that reveals to be very useful in sites where traffic comes from user comments. The two demos for django-comments-xtd are: … -
django CMS 2.3.3 released
-
Django cache templatetag with dynamic backend parameter
I've found a nice project django-adv-cache-tag. From the project website: With django-adv-cache-tag you can : add a version number (int, string, date or whatever, it will be stringified) to you templatetag : the version will be compared to the cached one, and the exact same cache key will be used for the new cached template, avoiding keeping old unused keys in your cache, allowing you to -
Pyramid, 2style4you and python - Wichert Akkerman
http://2style4you.com took up most of his time the last years: it provides automatic fashion recommendations for women. They use lots of technologies, for instance redmine, jenkins, transifex, bitbucket (git), zabbix. They had a lot of fashion portals that needed building. What did they need for them? There wasn't a lot of standard functionality that they needed, like form generation for database models. So there was a lot in the big web frameworks at the time (django, plone, zope) that they did not need. What they did need was customizability, all sites do things differently. And it needed to be fast. And internationalization was needed (he later showed a Taiwanese site, for instance). And he needed it to be in Python because Wichert knows that well. He started out with pylons, a mini framework. But after a while it wasn't really maintained anymore. Then they migrated to repoze.bfg (by Chris McDonough), another mini framework. They took about two months to migrate the whole thing (with the help of the repoze.bfg author). The fun thing is that repoze.bfg got merged into the pylons project later on; it is now called pyramid. They make a core website that provides the main functionality. Then … -
toastdriven/django-tastypie
toastdriven/django-tastypie. Hatte ich glaube ich schon mal, macht aber nix, sieht immer noch interessant aus – eine Alternative zu django-piston mit einer deutlich weitergehenden Funktionalität (zum Beispiel recht ausführliche Optionen für Authentifizierung und Authorisierung). Was es macht? REST Interfaces für Django Modelle inklusive deren Relationen. In den verschiedensten Formaten (XML, JSON, YAML). -
Django Extensions versioning a third option follow Django
After my previous post http://trbs.net/blog/2012/09/19/django-extensions-version-010-or-10/ and the many positive reactions I would like to suggest a third option. I didn't include this before because I wasn't yet sure if it would be a good option. But after some more thinking and reading Christophe31's suggestion which is very similar I think we should look seriously at the option :-) The idea is that we make Django Extensions follow the Django version numbers closely. This would mean bumping the version number to 1.4. With this scheme we would commit to the following in Django Extensions: * Django-Extensions 1.4 is compatible with Django 1.4 and it's deprecation timeline. * Django-Extensions will deprecate and update code on par with Django. (This would help us fix aka remove the tons of legacy/backwards compatibility hacks in the codebase) * A new version with bumped version number is released as soon as possible after a Django release. For a user it should be intuitive and clear that you should match the major version numbers of Django-Extensions to whatever version of Django you are using. This also solves questions like what version will support Python-3 or PyPy or deprecates using feature X. Some details would still need to … -
REST API creation with django-tastypie
django-tastypie is probably the best at the moment tool for REST API creation in Django applications. The code is on github and documentation is on readthedocs.org. With tastypie it's easy to create REST API that will allow easy web access to data stored in models - get, update, edit or delete. In this article I'll show some basic usage of tastypie. -
Load Testing with JMeter: Part 3 - Replaying Apache Logs
A while ago, I wrote a couple of blog entries about load testing with JMeter. I promised a third entry covering how to use JMeter to replay Apache logs and roughly recreate production load, but I never followed through with it. Today, I intend to rectify this grievous error. -
Django Extensions version 0.10 or 1.0
We are getting close to releasing a new version of Django Extensions to PyPi which means it's about time to bump the version number once again. Right now our version number is at 0.9 so the question becomes what do we use next ? We can go and continue to increment with +0.1 which will make this the 1.0 release. The thing for me with Django Extensions is that it's more a continuous process then something with 'stable' releases. What I mean is that as a collection of extensions there is really no such thing as a 'stable api/abi' as there is in a framework codebase like Django itself. So I don't mind either way. We can call it 1.0 and just increment that as long as we don't make any radical or major changes to the code base. Or just continue with the 0.x numbering for the time being. Please put your vote and/or thoughts about this in a comment at: https://github.com/django-extensions/django-extensions/issues/241 -
django CMS 2.3.2 released
-
Load Testing with JMeter: Part 3 - Replaying Apache Logs
Click here to see this post in it's natural habitat and to watch and leave comments. A while ago, I wrote a couple of blog entries about load testing with JMeter (Part 1 and Part 2). I promised a third entry covering how to use JMeter to replay Apache logs and roughly recreate production load, but I never followed through with it. Today, I intend to rectify this grievous error. Parsing your Apache Logs There is more than one way to do this, but my preferred method is to use a simple Python script to do some filtering of the Apache log file you want to use and to output the desired urls as a tidy CSV file. I am using the ‘apachelog’ module for this (also available as a gist): #!/usr/bin/env python """ Requires apachelog. `pip install apachelog` """ from __future__ import with_statement import apachelog import csv import re import sys from optparse import OptionParser STATUS_CODE = '%>s' REQUEST = '%r' USER_AGENT = '%{User-Agent}i' MEDIA_RE = re.compile(r'\.png|\.jpg|\.jpeg|\.gif|\.tif|\.tiff|\.bmp|\.js|\.css|\.ico|\.swf|\.xml') SPECIAL_RE = re.compile(r'xd_receiver|\.htj|\.htc|/admin') def main(): usage = "usage: %prog [options] LOGFILE" parser = OptionParser(usage=usage) parser.add_option( "-o", "--outfile", dest="outfile", action="store", default="urls.csv", help="The output file to write urls to", metavar="OUTFILE" ) parser.add_option( "-f", "--format", … -
Load Testing with JMeter: Part 3 - Replaying Apache Logs
A while ago, I wrote a couple of blog entries about load testing with JMeter (Part 1 and Part 2). I promised a third entry covering how to use JMeter to replay Apache logs and roughly recreate production load, but I never followed through with it. Today, I intend to rectify this grievous error. Parsing your Apache Logs There is more than one way to do this, but my preferred method is to use a simple Python script to do some filtering of the Apache log file you want to use and to output the desired urls as a tidy CSV file. I am using the ‘apachelog’ module for this (also available as a gist): #!/usr/bin/env python """ Requires apachelog. `pip install apachelog` """ from __future__ import with_statement import apachelog import csv import re import sys from optparse import OptionParser STATUS_CODE = '%>s' REQUEST = '%r' USER_AGENT = '%{User-Agent}i' MEDIA_RE = re.compile(r'\.png|\.jpg|\.jpeg|\.gif|\.tif|\.tiff|\.bmp|\.js|\.css|\.ico|\.swf|\.xml') SPECIAL_RE = re.compile(r'xd_receiver|\.htj|\.htc|/admin') def main(): usage = "usage: %prog [options] LOGFILE" parser = OptionParser(usage=usage) parser.add_option( "-o", "--outfile", dest="outfile", action="store", default="urls.csv", help="The output file to write urls to", metavar="OUTFILE" ) parser.add_option( "-f", "--format", dest="logformat", action="store", default=r'%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"', help="The Apache log format, copied … -
Goodbye django
It’s time to move on, on from Django to something else. I want to have a site that needs none or very little caretaking. Even if Gondor, Heroku et al make my work as a programmer much easier, but it’s not enough, I want things to be even easier. So I’m ditching Django and moving this blag to Pelican, a static site generator written in Python. Don’t worry, I will still use Django at work and for other projects, not just this one. -
Automated deployment with Ubuntu, Fabric and Django
A few months ago I started to play with Fabric and the result was a simple script that automates the creation of a new Django project. In the last months I continued my experiments and extended the script to a full stack for creation and deployment of Django projects. As the details behind the script like the project structure that I use and the server setup are a bit long I will keep this post only on the script usage and I will write a follow up one describing the project structure and server. So in a brief the setup that I use consist of Ubuntu as OS, Nginx as web server and uWSGI as application server. The last one is controlled by Upstart. The script is available for download at GitHub. In a wait for more detailed documentation here is a short description of the main tasks and what they do: startproject:<project_name> Creates a new virtual environment Installs the predefined packages(uWSGI, Django and South)) Creates a new Django project from the predefined template Creates different configuration files for development and production environment Initializes new git repository Prompts the user to choose a database type. Then installs database required packages, … -
Using vagrant for developing on OSX: why
All the years that I've used a mac, I've been doing my programming on the mac itself. OSX itself is a unix system, so that's fine. And with macports (or fink or that other one that I've forgotten) I can easily install the bunch of extra utilities that I need. When I worked with plone, this worked really well. The only external dependencies that you had to deal with were PIL (so: libjpeg-dev and friends) and sometimes lxml's libxslt/libxml dependencies. Especially lxml could give you grief on OSX, but with the use of the z3c.recipe.staticlxml recipe everything was fine. Django, which I work with now, is likewise easy to install and develop for on OSX. That is, until you get to geodjango. And we're using a whole lot of geo stuff in our websites, so you need a whole geo stack. Geos, gdal, mapnik. And often numpy and scipy. And spatialite instead of the bundled-with-python sqlite. All of this is just a big sudo apt-get install .... on ubuntu, but on OSX it is grief. I managed to get it working most of the time: I tried the kyngchaos packages first. Collecting everything and getting everything working with the right … -
Github filename convention for contributor information
I just saw a github blog post about contributing guidelines. If you place a CONTRIBUTING.txt (or .rst, or .md etc) in the root of your github repository, github will show a link to that file when someone adds an issue to the bug tracker (or when opening a pull request). Seems like a reasonable suggestion! So I tried it out in one of my open source projects. My main goals: I want it to sound friendly and welcoming. We actually want feedback and bug reports. Just sending an email is often easier and nicer. Especially if you just want to ask a question instead of adding a full-blown issue. When you're about to fix something yourself, I want to float a link to the developer information right in your face. How to run the tests. Explanation of the dependencies that are needed. That sort of stuff. So... this is my first try. Do you've got comments or tips? Do you think github's idea is handy? -
Nodejsconf 2012 Workshop - Conference - Hackathon ready for a 3-days Nodejs experience?
Nodejsconf 2012 Workshop - Conference - Hackathon ready for a 3-days Nodejs experience? (italian version below) The International European Node.js Conference, second edition, will be held on Saturday, November 10th in Brescia, Italy. Tickets are on sale: http://nodejsconf.it/#secIscrizione. Hurry up before they sell out like last year! We organized also two Node.js workshops the day before the conference, Friday November 9th. A beginner level workshop by Golo Roden and an advanced workshop by CleanCode (Gabriele Lana - Federico Galassi) http://nodejsconf.it/#secWorkshop Call for papers is open till Thursday September 20th and the final schedule will go online Tuesday September 25th. We would like to thank our bronze sponsors Ideato, CleanCode, the silver sponsor Incode, the gold sponsors Sintattica, Nearform and the platinum sponsors Libero Cloud and Microsoft Azure. We are also organizing an hackathon after the conference with TalentGarden, jsDay and Libero Cloud. Stay tuned, more info to come in the next days! The Libero Cloud platform will be used during the hackaton. The best hacks will be awarded with prizes and you can start using the Libero Cloud platform right now! You can get a 50€ voucher here. You also can try Windows Azure for free and the preview of Windows Azure Mobile … -
Nodejsconf 2012 Workshop - Conference - Hackathon ready for a 3-days Nodejs experience?
Nodejsconf 2012 Workshop - Conference - Hackathon ready for a 3-days Nodejs experience? body,.backgroundTable{ background-color:#eeeeee; } #contentTable{ border:0px none #000000; margin-top:10px; } .headerTop{ background-color:#26292e; border-top:0px none #000000; border-bottom:0px none #FFCC66; text-align:center; padding:0px; } .adminText{ font-size:10px; color:#333333; line-height:200%; font-family:Helvetica; text-decoration:none; } .headerBar{ background-color:#26292e; border-top:0px none #333333; border-bottom:0px none #FFFFFF; padding:0px; } .headerBarText{ color:#333333; font-size:30px; font-family:Helvetica; font-weight:normal; text-align:left; } .postcardBarText{ color:#333333; font-size:30px; font-family:Helvetica; font-weight:normal; text-align:center; } .title{ font-size:24px; font-weight:bold; color:#4A8797; font-family:Helvetica; line-height:150%; } .subTitle{ font-size:14px; font-weight:bold; color:#000000; font-style:normal; font-family:Helvetica; } .defaultText{ font-size:12px; color:#333333; line-height:150%; font-family:Helvetica; background-color:#FFFFFF; padding:20px; border:0px none #FFFFFF; } .footerRow{ background-color:#26292e; border-top:0px none #FFFFFF; padding:20px; } .footerText{ font-size:10px; color:#666666; line-height:100%; font-family:Helvetica; } a,a:link,a:visited{ color:#17488a; text-decoration:underline; font-weight:normal; } .headerTop a{ color:#26292e; text-decoration:none; font-weight:normal; } .footerRow a{ color:#465F5D; text-decoration:underline; font-weight:normal; } body,.backgroundTable{ background-color:#26292e; } (italian version below) The International European Node.js Conference, second edition, will be held on Saturday, November 10th in Brescia, Italy. Tickets are on sale: http://nodejsconf.it/#secIscrizione. Hurry up before they sell out like last year! We organized also two Node.js workshops the day before the conference, Friday November 9th. A beginner level workshop by Golo Roden and an advanced workshop by CleanCode (Gabriele Lana - Federico Galassi) http://nodejsconf.it/#secWorkshop Call for papers is open till Thursday September 20th and the …