Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Testing using a mocked HTTP server
Testing using a mocked HTTP server -
Weather App Tutorial. Part 2 of 5. Models
This is the second part of my tutorial how to make a weather app. This time I will show you how to create the models and set up the admin. Open the models.py file in the climate_change directory and enter the following: # -*- coding: UTF-8 -*- from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings class Location(models.Model): name = models.CharField(_("name"), max_length=200) location_id = models.CharField( _("location ID"), max_length=20, help_text=_("Location IDs can be retrieved from URLs of weather " "at specific cities at Yahoo! Weather, e.g. GMXX0008 from " "http://weather.yahoo.com/forecast/GMXX0008.html"), ) class Meta: verbose_name=_("location") verbose_name_plural=_("locations") def __unicode__(self): return self.name class WeatherLog(models.Model): location = models.ForeignKey(Location, verbose_name=_("location")) timestamp = models.DateTimeField(_("timestamp")) temperature = models.IntegerField(_("temperature (C°)")) humidity = models.IntegerField(_("humidity (%)")) wind_speed = models.DecimalField( _("wind speed (km/h)"), max_digits=5, decimal_places=2, ) visibility = models.DecimalField( _("visibility (km)"), max_digits=5, decimal_places=2, ) class Meta: verbose_name=_("weather log") verbose_name_plural=_("weather logs") ordering = ("-timestamp",) def __unicode__(self): return "%s @ %s" % ( self.location.name, self.timestamp.strftime("%Y-%m-%dT%H:%M"), ) The models are created. Now let's create the database schema for them. python manage.py syncdb Also in this step when asked, I created a superuser called "demo" to be able to access django-contributed administration. Let's try it out. We'll need to add a … -
Weather App Tutorial. Part 1 of 5. Preparation
It is Blog Action Day tomorrow so I decided to participate in it as a blogger again. The theme for this year is "Climate Change". After a little brainstorm, I came up with an idea to write a tutorial how to build an app which regularly checks local weather and lets you compare different weather features for months of different years.I'll use Yahoo! Weather to check the current weather. From all information that it provides, we'll be mostly interested in temperature, humidity, wind speed, and visibility in the current location. The app will check the weather regularly, will allow you to show the current weather, and also provide a graph comparing average monthly weathers throughout years.So let's start with the new project. I have quite a clean computer and want to do the app the nice way. So first of all, I will install virtualenv to be able to install third-party python libraries in a closed environment which will only be used for this project (I have already installed setuptools and django).# install virtualenvsudo easy_install virtualenvI created a directory Projects in my home directory and cd to it.Let's create a virtual environment and start the new project and app.# create … -
Fünftes Treffen der Django-UserGroup Hamburg
Das fünfte Treffen der Django-UserGroup Hamburg findet am Dienstag, den 27.10.2009 um 19:30 statt. Wie beim letzten Mal treffen wir uns wieder in den Räumen der CoreMedia AG in der Ludwig-Erhard-Straße 18 in 20459 Hamburg. Eine Anfahrtsbeschreibung gibt es auf der CoreMedia Webseite oder via Google Maps. Bitte am Eingang Ludwig-Erhard-Straße 18 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. Eingeladen ist wie immer jeder der Interesse hat sich mit anderen Djangonauten auszutauschen. Eine Anmeldung ist nicht erforderlich. Für ein paar Getränke wird wieder gesorgt sein, es ist aber durchaus erlaubt/erwünscht sich selbst Getränke und/oder etwas zu Essen mitzubringen. Weitere Informationen über die UserGroup gibt es auf www.dughh.de. -
Job opportunity: engineer at Whiskey Media
This is a paid advertisement. My friends and former co-workers at Whiskey Media are looking for a developer to join their team. I can’t possible say enough good things about Whiskey Media: it’s a smart, well-run company that’s using cool tech to accomplish great things. I worked for Whiskey Media for about a year, and they’re one of my clients at Revolution Systems. I’m happy to answer questions about the company; feel free to drop me an email. -
Actualización de seguridad Django 1.0 y 1.1
Hace un par de días se publicó una importante actualización de seguridad para Django 1.0, 1.1 y la versión de desarrollo. El agujero de seguridad afecta a cualquier aplicación que utiliza campos EmailField ó URLField en sus modelos. El fallo se debe a la validación de direcciones de e-mail y URLs mediante expresiones regulares. Algunas direcciones podían producir un rendimiento negativo en el sistema al aplicarles las expresiones regulares haciendo que el thread correspondiente dejara de responder y se consumieran más recursos de la CPU pudiendo resultar en una denegación de servicio si se hiciera deliberadamente. -
Optimising compilers are there so that you can be a better programmer
In a discussion on the Django developers mailing list I recently commented that the performance impact of having logging infrastructure, in the case where the user doesn't want the logging, could essentially be disregarded because Unladen Swallow (and PyPy) are bringing us a proper optimising (Just in Time) compiler that would essentially remove that consideration. Shortly thereafter someone asked me if I really thought it was the job of the interpreter/compiler to make us not think about performance. And my answer is: the job of a compiler is to let me program with best practices and not suffer performance consequences for doing things the right way.Let us consider the most common compiler optimisations. A relatively simple one is function inlining, in the case where including the body of the function would be more efficient than actually calling it, a compiler can simply move the functions body into its caller. However, we can actually do this optimisation in our own code. We could rewrite: def times_2(x): return x * 2 def do_some_stuff(i): for x in i: # stuff z = times_2(x) # more stuffas: def do_some_stuff(i): for x in i: # stuff z = x * 2 # more stuffAnd this … -
Django and ASP.NET MVC
While looking at some blogs and news sites about the MVC web-frameworks, I stumbled upon a nice stack overflow question: ASP.NET MVC vs. Django - Which framework should I learn? The answers have a lot of interesting points. For example one argument pro django by user saner is that: Django is more mature and there are a lot of available components you can use. There is ORM so using database is very easy. Testing is simple and community is very responsive. Another user, Oko, suggests that django is newbie friendly: To start working with django, you don't have to be experienced Python programmer. If you are generally oriented in web development, you will find yourself working with django in no time. For the ASP.NET MVC side of things, Lau Franco gives one possible advantage for people who don’t know neither of the frameworks: …with ASP.NET MVC, you only need to learn the new framework. For Django, you also need to learn how to deploy, host and keep the site running (which means learning Apache and tools for dealing with it). Regardless of whether the above opinion is true or not, I think ASP.NET MVC has a good chance of gaining … -
The Mythical Django Pony, a blessing?
On my way to have lunch on the first day of DjangoCon in Portland, I met Eric Holscher in one of the corridors of the hotel holding a pink unicorn. It seemed odd to me so I approached and asked him about what he had in his hands. He explained that this was the unofficial Django mascot, which was a pony. I didn’t make the obvious observation that what he had in his hands was a unicorn, but asked how this came to be. He explained that one of the core dev on the Django mailing list responded to one of the feature requests saying “no, you can’t have a Pony!” as a way of politely refusing the feature request. I was surprised to be in a DjangoCon session two days later where Russell Keith-Magee talks about declined feature requests and how they are referred to as ponies, and suggests ways in which your features are likely to get accepted. He also explained the whole story behind the mythical Django pony (which is really a unicorn!). Why am I bringing this up now? well as I write the concluding chapters of my dissertation, I notice an odd relationship between the number of … -
* is Unix
Ryan’s I like Unicorn because it’s Unix appears to have started a mini-meme of folks writing simple forking network servers in their language of choice. I’m really enjoying reading ‘em – they’re a sort of Rosetta Stone of network code – so I’m going to keep a running list of links here. Tell me about any I’ve missed (via email, comments, or twitter) and I’ll add ‘em to the list. -
Python is Unix
Ryan Tomayko’s I like Unicorn because it’s Unix should be required reading for anyone doing anything involving networks or unixes these days. Like Ryan, I share a deep appreciation for the dark art of Unix system calls, and like Ryan I’m a bit dismayed to see them relegated to the dusty corners of our shiny dynamic languages. So I read I like Unicorn because it’s Unix with glee; it’s perhaps the cleanest, clearest explanation of how preforking socket servers work, and I enjoyed seeing Ruby’s twist on the old standard. -
BBCode and Syntax Highlighting with Django
Lightweight BBCode parser and syntax highlighting for Django. Code blocks set off with the tag will be automatically highlighted. -
Customising Django-Mingus
This blog is built using Kevin Fricovsky's excellent django-mingus project, which is mainly a set of standard pre-existing reusable apps with some templates and a bit of glue to hold it together. Although it's quite usable out of the box, I found - inveterate hacker that I am - that there were several things that I didn't quite like in the project as it was. So I changed them (isn't open source great, laydees-n-genelmen). At some point I'll fork the project on github and upload the changes, but for now here's what I've done. Firstly, mingus forsakes Django's built-in comments framework for the external Disqus project. I didn't really fancy signing up for another service - especially as I'm not expecting vast numbers of comments on this blog. It's quite a simple matter to reinstate the comments - the relevant template code is included in the post_detail.html template included with the basic-blog app which mingus extends, so I just needed to copy and paste it into the mingus version. Then add (r'comments/', include('django.contrib.comments.urls')), to urls.py, django.contrib.comments to settings.py, run a syncdb and it's all done. There are however a couple of missing pieces here. basic-blog doesn't include templates for the … -
Customising Django-Mingus
This blog is built using Kevin Fricovsky's excellent django-mingus project, which is mainly a set of standard pre-existing reusable apps with some templates and a bit of glue to hold it together. Although it's quite usable out of the box, I found - inveterate hacker that I am - that there were several things that I didn't quite like in the project as it was. So I changed them (isn't open source great, laydees-n-genelmen). At some point I'll fork the project on github and upload the changes, but for now here's what I've done. Firstly, mingus forsakes Django's built-in comments framework for the external Disqus project. I didn't really fancy signing up for another service - especially as I'm not expecting vast numbers of comments on this blog. It's quite a simple matter to reinstate the comments - the relevant template code is included in the post_detail.html template included with the basic-blog app which mingus extends, so I just needed to copy and paste it into the mingus version. Then add (r'comments/', include('django.contrib.comments.urls')), to urls.py, django.contrib.comments to settings.py, run a syncdb and it's all done. There are however a couple of missing pieces here. basic-blog doesn't include templates for the … -
Using Zoho remote API to edit office documents in a Django app
An introduction to Zoho.com APIs, CloudSQL, and sample usage of Remote API to edit documents, slides and sheets on a Django powered website. Full source code of the app included. -
Custom JOINs with Django's query.join()
Django's ORM is great. It handles simple to fairly complex queries right out the box without having to write any SQL. If you need a complicated query, Django's lets you use .extra(), and you can always fallback to raw SQL if need be, but then you lose the ORM's bells and whistles. So it's always nice to find solutions that allow you to tap into the ORM at different levels. -
Simple MySQL Backup at Google Code
A while ago I wrote an article about a script I created to backup databases. Since then I had to make little changes and decided to put it to Google code as Open-Source-Project and released the new version 0.1.1 with some minor changes. If you're interested in the script, head over to its project page and check the appropriate pages like the Changelog and the Installation and Requirements page. Feel free to download and comment it. UPDATE: You can find the project now on github! -
Simple MySQL Backup at Google Code
A while ago I wrote an article about a script I created to backup databases. Since then I had to make little changes and decided to put it to Google code as Open-Source-Project and released the new version 0.1.1 with some minor changes. If you're interested in the script, head over to its project page and check the appropriate pages like the Changelog and theInstallation and Requirements page. Feel free to download it. UPDATE: You can find the project now on github! -
Simple MySQL Backup at Google Code
A while ago I wrote an article about a script I created to backup databases. Since then I had to make little changes and decided to put it to Google code as Open-Source-Project and released the new version 0.1.1 with some minor changes. If you're interested in the script, head over to its project page and check the appropriate pages like the Changelog and theInstallation and Requirements page. Feel free to download it. UPDATE: You can find the project now on github! -
Simple MySQL Backup at Google Code
A while ago I wrote an article about a script I created to backup databases. Since then I had to make little changes and decided to put it to Google code as Open-Source-Project and released the new version 0.1.1 with some minor changes. If you're interested in the script, head over to its project page and check the appropriate pages like the Changelog and theInstallation and Requirements page. Feel free to download it. UPDATE: You can find the project now on github! -
Django training and 'Last page visited' middleware
I've been lucky enough to have spent this week attending Jacob Kaplan-Moss's Django Training. One of the topics we covered a bit later in the week was middleware, which in the Django usage is somewhat of a misnomer. Middleware in Django allows you to pre-process requests, post-process responses, and handle exceptions. -
On Django and Check Constraints
I've come to love Django, and now I seem to be spending not only my work time, but also my own time working on one django project or another. Today at work I came across the need to have check constraints in a database. For instance, this can be used to ensure that the start of an event is before the end of the event, or that a certain value has a particular range of values. For the SQL savvy, it can look like: {% highlight sql %} CREATE TABLE event ( ...more columns here... start datetime, finish datetime, count integer CHECK (count >= 0), CONSTRAINT event_starts_before_finish CHECK (start < finish) ); {% endhighlight %} There are two types of constraint here: the column-level constraint, which in this instance can be done with django, and the table-level constraint, which in many systems cannot be a part of a column definition. In PostgreSQL, my DBMS of choice, it is possible to define a constraint that affects more than one column as part of a column, but I prefer not to. Note also that I am using the syntax form that allows me to name the constraint. This means I can alter … -
Django Fixtures
A fixture is basically a data dump in a specific format. There is no restriction of which models or how much data a fixture can contain. Fixtures are portable. They work the same with all the database backends and operating systems supported by Django. This means that you can use fixtures as a simple data [...] -
Web Developer for Hire
We're pleased to announce that Caktus is looking for a developer to join our team on a contract basis! What do we do? We build custom web applications for local and remote clients using a variety of open-source technologies. We are a small team founded in the Chapel Hill/Carrboro area (currently residing in Carrboro Creative Coworking) who believe in face-to-face contact and employ agile development techniques that emphasize teamwork and collaboration. -
Moving from Django to Plone
This is the first of what might be a series of posts about learning Plone. I’ve worked in Django since January 2006, when Joe Heck, Karen Williams, and I built the now-defunct TrenchMice site. I haven’t done any Django work since March, when I joined Fisher Communications, but I’ve followed the mailing lists and blogs. And I [...]