Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Make runfcgi fail when database connection is open before fork
Make runfcgi fail when database connection is open before fork. Das ist eine Sache nach der ich schon ewige Zeiten jage, zuletzt in ein paar ziemlich wichtigen Projekten. Flup arbeitet so, dass es die WSGI-Anwendung erst initialisiert und mit dieser initialisierten WSGI Anwendung dann die Forks für die Worker macht. Dummerweise gibt es bei uns aber Datenbankzugriffe wärend der Anwendungsinitialisierung – dadurch hat der Basisprozess schon eine offene Datenbankverbindung, jeder Fork kopiert diese Daten. Aber der Socket der Verbindung geht natürlich nicht mit – der neue Prozess denkt nur er wäre verbunden, ist es aber nicht. Zugriffe von denen neuen Prozessen fallen dann mit einer Exception raus. Man kann im verlinkten Patch auch gut den raise auf die Exception einfach durch connection.connection = None ersetzen. Dann wird einfach die Verbindung die sowieso defekt ist weggeworfen und in neuen Prozessen immer eine neue Verbindung aufgebaut. Damit haben wir zumindestens in einem Produktionsumfeld (mit psycopg2) das ganze beheben können und sind guten Mutes, dass es auch bei der Umgebung mit pyodbc helfen wird. -
Django verbose_name in your template
There are many situations when you want to display model field verbose_name in template when displaying tables and other data. Ideally you would put this value in header section of your table for DRY purposes. The problem is that it's unable to use model _meta in templates. You can achive the same using an example verbose_name_tags.py templatetag. # verbose_name_tags.py from django import -
Never fix a bug twice
Noah Sussman wrote a post on Things you should test, “A checklist of things that are worth testing in pretty much any software system.” Many of the things on the list are helpful reminders. However, I think the mindset it encourages is essentially wrong. The mindset is basically this: Identify common mistakes that developers make, and ensure you are writing tests that check you haven't made them. The problem with this approach is that it is essentially whack-a-mole debugging. There is a never ending supply of bugs to kill. A much more helpful approach is found in this post on easy programming that advocates “Never fix a bug twice” (about one-third of the way down). If you come across a bug or class of bugs that often occur, you should not be thinking first of all “better add that to my list of classes of bugs that need testing against”. You should rather be thinking “how can I change the system so that this class of bugs disappears entirely?”. So, to take some of items listed for testing: Input handling bugs, such SQL injection and XSS attacks. In Django apps, I never write tests for SQL injection attacks or XSS … -
PostgreSQL and PostGIS installation from source on Mac OS X Lion
This is a cookbook for installing PostgreSQL and PostGIS on Mac OS X Lion from source, as alternative you can install the binaries from EnterpriseDB or KyngChaos. You don't have to install all packages but if you're using Django will be useful. Requirements Xcode with "Command Line Tools": Installation via Xcode > Preferences > Downloads. PostgreSQL Create the postgres user via System Preferences(for simplicity), use "postgres" as username. Compiling and installing PostgreSQL: $ curl -O http://ftp.postgresql.org/pub/source/v9.1.3/postgresql-9.1.3.tar.gz $ tar xzfp postgresql-9.1.3.tar.gz $ cd postgresql-9.1.3 $ ./configure CC=/usr/bin/clang CXX=/usr/bin/clang++ "CFLAGS=-arch x86_64" "LDFLAGS=-arch x86_64" "CXXFLAGS=-arch x86_64" $ make $ sudo make install $ cd .. Create PostgreSQL Database Cluster: $ sudo mkdir /usr/local/pgsql/data $ sudo chown postgres /usr/local/pgsql/data $ sudo -u postgres /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data Start PostgreSQL Server: $ sudo -u postgres /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data start After installation add to .profile or .zshrc: export PATH=/usr/local/pgsql/bin:$PATH PROJ4 PROJ.4 is a library for converting geospatial data to different coordinate reference systems. $ curl -O http://download.osgeo.org/proj/proj-4.8.0.tar.gz $ curl -O http://download.osgeo.org/proj/proj-datumgrid-1.5.zip $ tar xzfp proj-4.8.0.tar.gz $ cd proj-4.8.0/nad $ unzip ../../proj-datumgrid-1.5.zip $ cd .. $ ./configure CC=/usr/bin/clang CXX=/usr/bin/clang++ "CFLAGS=-arch x86_64" "LDFLAGS=-arch x86_64" "CXXFLAGS=-arch x86_64" $ make $ sudo make install $ cd .. GEOS GEOS is a … -
#18251 multithreading deadlock in django.models.loading.get_apps – Django
#18251 multithreading deadlock in django.models.loading.get_apps – Django. Und noch eine Sache, die uns vielleicht betreffen könnte – Raceconditions zwischen Django-Threads bei der Initialisierung von Django-Applications. Gibt auch schon einen Patch dafür, der das in den Django Internals behebt. -
Using SELECT FOR UPDATE in Django
Using SELECT FOR UPDATE in Django. Drin was dran steht. Denn der Django ORM kann derzeit keinen SELECT FOR UPDATE erzeugen, aber manchmal braucht man ihn einfach. -
DjangoSites Move Complete
I've finished migrating DjangoSites to it's new home, and everything should be back online. I've got a few tips for migrating simple Django-powered sites if you click through to read the rest of this blog post. -
DjangoSites Move Complete
For the past few years I've hosted all of my projects on a single RimuHosting VPS. It's old, running Debian 5.0, and maintenance and upgrades have become headachy. It isn't easy to run Python 2.7 on old Debian versions, and since I only started using virtualenv relatively recently, things were a real mess. As such, it was time to upgrade the VPS. I made the decision to look around for other hosting options, and eventually settled on Prgmr as the performance-for-dollar ratio seemed much higher to me. I've taken the opportunity to break things down into multiple smaller VPS units to try and keep maintenance somewhat simpler. I can pull a single site's server down without breaking any other sites, and I can upgrade components individually for a single site. Prgmr's pricing makes this possible: Their 'base' is very low - you pay $4 for each VPS plus RAM. Djangosites.org now sits on it's own 512mb Prgmr Debian 6.0 instance. With 128mb taken up with memcached and a small portion to nginx and the operating system, there's plenty of RAM left for my gunicorn worker processes. So how did I move everything across? Although it took me 3 days to … -
DjangoSites Move Complete
For the past few years I've hosted all of my projects on a single RimuHosting VPS. It's old, running Debian 5.0, and maintenance and upgrades have become headachy. It isn't easy to run Python 2.7 on old Debian versions, and since I only started using virtualenv relatively recently … -
Making the django foreign key admin widget more useful
Thanks to a user at Django-snippets, I was able to quickly create an app containing a widget for displaying icons along side the normal related widget for foreignkey fields. The result looks like this: It’s pretty easy to use. Check it out on Github! -
Mining the Social Web: for fun , profit and satisfaction
I have recently read "Mining the social web" By Matthew A. Russell. It was part of my "big data & Natural Language" master plan, and, since the example were in python it looked as a good read. And it is! This is a review I completly agree with: Mining the Social Web is a good start for anyone is going to create scripts to analyze patterns in Social Networks. I've to say that this book -
Using Factory Boy in Django application tests
Factory Boy is a fixtures replacement for Django tests (and not only). In an easy and manageable way you can create and maintain data needed for tests. Fixtures can be hard to maintain. Direct ORM usage isn't the best thing too. Factory Boy is here to help... You can find Factory Boy on github. There is also full documentation of the project. Factory Boy allows you to create factories for models (not only for models). A factory is something like a wrapper that provides data required for object creation. -
Neo 4J Graph Database
In this post, I will give a brief introduction to Neo 4J database, installation and basic usage with JAVA . Firstly, Neo4J is a NO-SQL database. It is used to store data in the form of a graph data structure , i.e. a structure having nodes and edges(called relationships) among the various nodes. This form of database finds its use case in many applications such as storing a social network in systems like facebook , twitter ,etc . More information on what Neo 4J can be found here . Now, coming to the setup of neo 4J graph database. You can download the installation package from the official site here. Save the tar in a local folder and extract the contents. For this post I am going to run a sample code in neo 4j using eclipse(Details about eclipse can be found here). Open the eclipse IDE and create a new project , say “firstNeo4jApp”. Add a class named graphDb.java in the default package. Now here comes the important step, to add the neo4j libraries to the build path of eclipse.(Improperly configured build path can lead to errors while compiling the code). To add the neo4j libraries , right click … -
django CMS 2.3 release candidate 1 available
-
Unofficial mercurial mirror for Django that works
The documentation for Django mentions an “official” mirror for mercurial. Django got us used to a very high standard when it comes to quality. Unfortunately, this is exactly the contrary for this mirror. It’s quite often broken, or not updated, or both. The last itch is that nobody has taken care of it since the […] -
Django-floppyforms 1.0 released
I just pushed django-floppyforms 1.0 to the cheese shop. The previous version (0.4.7) was published quite some time ago and a couple of things happened since then. What is django-floppyforms? This project started from too much frustration trying to customize form widgets in Django. It lets you customize the output of forms using Django templates instead of python code. So, what's new in 1.0? Gregor Mülleger did a GSoC project on Django last summer, aiming to switch Django forms to template-based rendering. His work didn't get merged in Django itself for performance concerns with regards to the Django Template Language but has been added to floppyforms by Jannis Leidel. There is now a nice layout API that lets you completely customize the way forms are rendered. As a side effect, Jannis and Gregor are core committers on the project! Django 1.2 support was dropped, only Django 1.3 and above are supported. Select widgets now support <optgroup>. This change is backwards-incompatible if you have any custom templates for Select widgets and friends (SelectMultiple, CheckboxSelectMultiple, etc.) Keep an eye on them while upgrading. Various areas of the code are now more robust and better tested. If you are hesitant to use it … -
Python is not a Panacea …
… neither is any other language or framework This post was inspired by the serial discussion on the topic “Python vs other language”(in the specific case the other one was PHP, and the question was asked in a Python group so you may guess whether there are any answers in favor of PHP). It is very simple, I believe that every Python developer will tell you that Python is the greatest language ever build, how easy is to learn it, how readable and flexible it is, how much fun it is to work with it and so on. They will tell you that you can do everything with it: web and desktop development, testing, automation, scientific simulations etc. But what most of them will forgot to tell you is that it is not a Panacea. In the matter of fact you can also build “ugly” and unstable applications in Python too. Most problems come not from the language or framework used, but from bad coding practices and bad understanding of the environment. Python will force you to write readable code but it wont solve all your problems. It is hard to make a complete list of what exactly you must … -
DjangoSites Downtime - Server Move
Heads-up: DjangoSites.org will be down, at some point in the next week, while I move it to a new server. Expected downtime is approximately 1 hour to transfer files & database; if your ISP has DNS servers that don't observe TTL then you might not see updates for a while longer. -
DjangoSites Downtime - Server Move
Heads-up: DjangoSites.org will be down, at some point in the next week, while I move it to a new server. Expected downtime is approximately 1 hour to transfer files & database; if your ISP has DNS servers that don't observe TTL then you might not see updates for a while longer. This is happening as I'm moving DjangoSites to it's own VPS to make it easier to balance available resources between it and my other projects. -
DjangoSites Downtime - Server Move
Heads-up: DjangoSites.org will be down, at some point in the next week, while I move it to a new server. Expected downtime is approximately 1 hour to transfer files & database; if your ISP has DNS servers that don't observe TTL then you might not see updates for a while … -
Coding from the inside
Some time ago, a message on the Evennia mailing list asked about "softcode" support in Evennia. Softcode, a defacto standard in the MUX/MUCK/MUSH/MOO world, is conceptually a "safe" in-game scripting language that allows Players to extend the functionality of things without having access to the server source. Now, Evennia is meant to be extended by normal Python modules. For coding game systems and advanced stuff, there is really no reason (in my opinion) for a small development team to not use a modern version control system and proper text editors rather than entering things on a command line without formatting.But there is a potential fun aspect of having an online scripting language - and that is player content creation. Crafters wanting to add some pizazz to their objects, builders getting an extra venue of creativity with their rooms - that kind of thing. I didn't plan to add softcode support to Evennia, but it "sounded like an interesting problem" and one thing led to another. Python is of course an excellent scripting language from the start. Problem is that it's notoriously tricky to make it run safely with untrusted code - like that inserted by careless or even potentially malignant … -
My Trip To Djangocon 2012 Zurich
I'm back from my trip in Zurich for the 2012 european Django Conference. It was great! Great talcks, great organization, free snacks, good WIFI and amazing location. The venue Stadion Letzigrund... a conference in a stadium foyer? YES great idea the location was perfect may be a bit cold in te morning but great talks and a hundreds of laptops wormed it up easly. The topics The trendy -
Announcing PyCon Philippines!
PyCon Philippines 2012, set to occur on June 30 and July 1, is the first Python programming conference held in the Philippines. PyCon is a volunteer run effort that brings together Python developers from a variety of backgrounds and skill levels into a friendly, cooperative environment in order to educate, inspire, and work together - building relationships that transcend the event and can turn into lifelong friendships or even very impressive business alliances. This event is possible due to the hard work and contributions of members of the Manila Python users group, the support of the Python Software Foundation, various members of the Python community, our gracious sponsors, and many others. I'll be there, along with Audrey Roy and Django core developer Malcolm Tredinnick. Hope to see you there! What is Python? Python is an open source programming language used for science, engineering, robotics, entertainment, web development, and more. It is used by organizations such as Google, NASA, Instagram, Pinterest, Mozilla, Walt Disney Animation Studios, WETA Digital, and many more. Interested in attending? Then head to the registration page. The early bird discount ends on June 15th, so buy your tickets now! Interested in sponsoring? Please go to the sponsorship … -
Announcing PyCon Philippines!
PyCon Philippines 2012, set to occur on June 30 and July 1, is the first Python programming conference held in the Philippines. PyCon is a volunteer run effort that brings together Python developers from a variety of backgrounds and skill levels into a friendly, cooperative environment in order to educate, inspire, and work together - building relationships that transcend the event and can turn into lifelong friendships or even very impressive business alliances. This event is possible due to the hard work and contributions of members of the Manila Python users group, the support of the Python Software Foundation, various members of the Python community, our gracious sponsors, and many others. I'll be there, along with Audrey Roy and Django core developer Malcolm Tredinnick. Hope to see you there! What is Python? Python is an open source programming language used for science, engineering, robotics, entertainment, web development, and more. It is used by organizations such as Google, NASA, Instagram, Pinterest, Mozilla, Walt Disney Animation Studios, WETA Digital, and many more. Interested in attending? Then head to the registration page. The early bird discount ends on June 15th, so buy your tickets now! Interested in sponsoring? Please go to the sponsorship … -
Testing with Jenkins, Selenium and Continuous Deployment
My presentation at KharkivPy#4 about Selenium, Jenkins and Continuous Deployment. A lot of people asket me about code samples. There's no samples. There's no python code at all in this presentation. The main purpose of this presentation is that you can build full cycle testing for your project easy enough.For example by using tools like Fabdeploy or even raw FabricTesting with Jenkins, Selenium and Continuous Deployment View more presentations from Max KlymyshynUpdate: video of this presentation in russian