background preloader

Django

Facebook Twitter

Pennersr/django-jhouston - GitHub. #16778 (Bad geometry escape in postgis) Getting Started with Testing in Django. Following yesterday's post another hotly requested topic was testing in Django. Today I wanted to give a simple overview on how to get started writing tests for your Django applications. Since Django 1.1, Django has automatically provided a tests.py file when you create a new application, that's where we'll start. For me the first thing I want to test with my applications is, "Do the views work? ". This makes sense, the views are what the user sees, they need to at least be in a working state (200 OK response) before anything else can happen (business logic). So the most basic thing you can do to start testing is something like this: from django.tests import TestCase class MyTests(TestCase): def test_views(self): response = self.client.get("/my/url/") self.assertEqual(response.status_code, 200) By just making sure you run this code before you commit something you've already eliminated a bunch of errors, syntax errors in your URLs or views, typos, forgotten imports, etc.

Graphically designing Django models

Django | The Web framework for perfectionists with deadlines. Kraftwerk WSGI. The third style of Django multilingual data handling - Rafał Jońca [Blog] Django Fiber - a simple, user-friendly CMS for all your Django proj... Django-Graphs – Trac. Irrational Exuberance: Dreamier Dream Server with Nginx. 2009/2/13 An updated version of this article using Ubuntu Intrepid can be viewed here. In my previous setup there were some concerns with the way I was using mod_proxy. The issue is that a request comes in and is received by Apache, if it was a media file Apache would then pass the request to Lighttpd, which would pass the file to Apache, which would then pass the file to the requester. Obviously, this is batshit crazy. This is why I have reworked my instructions with fewer catastrophic mental lapses.

The article has also been reworked for conciseness, and all sections on security have been removed, you can refer back to the original article, but should ideally look for a more specialized resource on securing your server. The bulk of the process is unchanged, but we will now be using Nginx as a frontend proxy and static media server, and Apache2 with mod_python as the backend server for handling Django. Also relevant is the fact that Lighttpd has an annoying memory leak. End Product. Hacking comments in Django 1.0. The recent release of Django 1.0 included a full rewrite of the comments framework.

Comments have been available in Django for a while but were never properly documented until now. This article will show you how to adapt and extend the comments framework so that it fits the needs of your application. Why extend it? Well, mainly because the framework does what it says on the box—and nothing more. It allows you to attach comments to any Django object instance but for the rest of the business logic—e.g. regulating who can modify and delete comments—you are on your own. Also, the current documentation does not cover all features so what I am writing here should hopefully fill a few gaps. Prerequisites You need to be familiar with Django. How comments work It’s really simple—just skim through the well-written documentation and you should pretty much be able to figure it out. 1.{% load comments %} 2.{% render_comment_form for my_model_instance %} The scenario The problem Step 1: Enabling comments 5.

StaticGenerator for Django. Django-gadgets - Google Code. Django-evolution - Google Code. When you run . /manage.py syncdb, Django will look for any new models that have been defined, and add a database table to represent those new models. However, if you make a change to an existing model, . /manage.py syncdb will not make any changes to the database. This is where Django Evolution fits in. Django Evolution is a work in progress. If you have any questions that aren't covered by the FAQ and/or documentation, there is a mailing list where you may be able to get answers. Django Evolution requires features that are only available in Django v1.0 or higher. Django Evolution doesn't support all of Django's database features. Installation To install Django Evolution, simply run: $ easy_install -U django_evolution You can also check out Django Evolution from the SVN repository. Using Django Evolution in your project Add django_evolution to the INSTALLED_APPS for your project Run .

Writing Python Code That Doesn't Suck. Note: this is ultimately intended for the biology-in-python Wiki at I will release it under a CC license, so please feel free to use it for your own site! --titus Here are some prescriptions for writing Python code that other Python programmers will find more usable and readable than it might otherwise have been.

This advice is intended for people writing anything more advanced than isolated code snippets: anything that you might eventually want to release, for example, or share with other people. Organize your code Be systematic in the way you organize your code. Module filenames must be valid Python identifiers, but scripts should use '-' instead of '_' (which renders them non-importable).use shallow package hierarchies for naming, e.g.import pkg.fasta_ioinstead ofimport pkg.seq.readers.file_readers.fastaThe latter one may seem better organized, but no one will ever remember the whole package name! Use setup.py and Distutils Provide Automated Tests Conclusions. Science, technology, health, climate. Some Notes on Moving the Zone to Django. Fredrik Lundh | August 2007 Added sections on caching and resource “minification”.

The effbot.org “zone” is a constantly growing collection of documents, most of them concerning various aspects of Python and related technologies. The zone software is also used for my PIL and Tkinter documentation, the online edition of my Python Standard Library book, and a couple of other document collections. All in all, the zones at effbot.org currently contain around 2,000 documents, plus some 500 user comments. Until now, the zone has been served as static HTML, generated and maintained using an increasinly disorganized collection of CGI scripts and off-site tools.

Design My original plan was to use the old effbot.org templates pretty much as they were, but all recent talk about CSS frameworks , and how they’d ruin the field of web design by leaving it open for people who just cannot be bothered to learn everything there is to know about cross-platform CSS inanities, made me curious. Performance. An Honest Look at Django « we are symple. I’ve written a few posts on Django and those were mostly a response to Django’s admin interface.

However, when I switched to building a web application in Django instead of Ruby on Rails, I saw the benefits immediately. Faster, easier and more productive. Period. In Rails there are different ways to do anything. The approaches can become easily unlimited depending on your skill level. For a developer like myself who is primarily a designer, it seemed less appealing that I had to spend 60% of my time learning how to do it right. Don’t get me wrong, I want to do it right. I’m almost positive there are plenty who disagree, but the fact of the matter is your disagreement is irrelevant cause you’re not me. This is where I came back to Django. Why Django over Rails? Deployability – Rails is not easy to deploy on shared host environments. Those are just a few things Django has proved itself in and as time moves on, I will post more about how Django does documentation. Like this: Like Loading... Django Master Class. The earth, while not flat, is also not round. It’s round-ish, with lots of inconvenient bumps and dips.

An ellipsoid is a sort-of-earthy shape that’s easier on the computer processor. Since it’s not quite right, datums are used to choose a specific area of the earth for which the distortion is minimized for the chosen ellipsoid. (Diagram needed) Unit systems are things like metric, lat/lon, and radian. They’re various ways to describe a given point or distance. Axes and Origins are the orientation and starting point for a coordinate system. Projections are various ways of distorting the ellipsoid onto a flat surface. The governments, a while back, wanted to accurately fire long range missiles at each other, and GPS came out of that.

Instant Django. Python Tutorials, more than 300, updated April 16, 2006, and carefully sorted by topic and category.