Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Dying NTP deamons on vsphere vmware machines
We (Nelen & Schuurmans) have quite some servers. Most of them are vmware virtual machines in a vshpere cluster. Once in a while, one or more of the machines got reported by our monitoring tool (zabbix) as having a time drift problem. Weird, as we have NTP running everywhere. And weird if you look at django logfiles and see a negative jump in time all of a sudden. We run ntpd everywhere to keep the time in sync with two windows domain servers. Every time a server drifted, the ntpd daemon turned out to have died. Without leaving any trace in any logfile. ntpd kills itself when the time drift is more than 20 minutes or so, assuming that it hurts more than it helps. There's a switch to prevent this self-killing behaviour, but ntpd killed itself anyway. In the end, an external sysadmin found the problem: One of the physical vsphere host machines (big server, lots of blades) was mis-configured: the ntp daemon on the host machine itself was configured, but it was not configured to automatically start when you start up the server... This host machine started to drift its time, naturally. Several actions vsphere does on a … -
Checking for Python version and Vim version in your .vimrc
Recently I’ve had to adjust a bunch of my dotfiles to support some old (Centos 5) systems which means that I am using a Vim that has Python 2.4 build in… needless to say, it breaks some of my dotfiles So here’s some tips on patching Vim version issues. First, checking if you have Python in your Vim and which version you are using. It returns a version similar to how Vim does it with it’s version. So 204 is the result for Python 2.4, 207 for Python 2.7 and so on. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Check python version if available """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" if has("python") python import vim; from sys import version_info as v; vim.command('let python_version=%d' % (v[0] * 100 + v[1])) else let python_version=0 endif Now we can make plugins/bundles dependend on versions: if python_version >= 205 " Ultisnips requires Vim 2.5 or higher due to the with_statement Bundle 'SirVer/ultisnips' else Bundle "MarcWeber/vim-addon-mw-utils" Bundle "tomtom/tlib_vim" Bundle "garbas/vim-snipmate" endif And checking for the Vim version to see if features are available: if version >= 703 set undofile set undodir=~/.vim/undo set undolevels=10000 call system('mkdir ' . expand('~/.vim/undo')) endif That’s it, the examples can be found in my Vim config: https://github.com/WoLpH/dotfiles/blob/master/_vimrc Link to this post! -
Bangalore Django User Group - Beginners Workshop
During BangPypers december dev sprint Few weeks back, Krace & Siva asked me if I can take a Django workshop. I agreed. They have worked on logistics & scheduled for February at IBM, Domlur.I reached there by 9.30 AM. 26 people attended the session. Due to some problems we started a bit late than what we have planned. Krace, Siva & Ankur assisted a lot during the session.We planned to cover the basics of Django & CRUD operations by building a simple app. We covered basics & simple create view. Due to time constraint we were unable to cover the remaining.Content: https://github.com/ChillarAnand/django-bookmarksSlides: http://chillaranand.github.io/django-bookmarks/ -
A method for rendering templates with Python
I never intended to write a template system for Moya. Originally, I was going to offer a plugin system to use any template format you wish, with Jinja as the default. Jinja was certainly up to the task; it is blindingly fast, with a comfortable Django-like syntax. But it was never going to work exactly how I wanted it to, and since I don't have to be pragmatic on my hobby projects, I decided to re-invent the wheel. Because otherwise, how do we get better wheels? The challenge of writing a template language, I discovered, was keeping the code manageable. If you want to make it both flexible and fast, it can quickly descend in to a mass of special cases and compromises. After a few aborted attempts, I worked out a system that was both flexible and reasonable fast. Not as fast as template systems that compile directly in to Python, but not half bad. Moya's template system is about 10-25% faster than Django templates with a similar feature set. There are a two main steps in rendering a template. First the template needs to be tokenized, i.e. split up in a data structure of text / tags. This … -
A simple method for rendering templates with Python
I never intended to write a template system for Moya. Originally, I was going to offer a plugin system to use any template format you wish, with Jinja as the default. Jinja was certainly up to the task; it is blindingly fast, with a comfortable Django-like syntax. But it was never going to work exactly how I wanted it to, and since I don't have to be pragmatic on my hobby projects, I decided to re-invent the wheel. Because otherwise, how do we get better wheels? The challenge of writing a template language, I discovered, was keeping the code manageable. If you want to make it both flexible and fast, it can quickly descend in to a mass of special cases and compromises. After a few aborted attempts, I worked out a system that was both flexible and reasonable fast. Not as fast as template systems that compile directly in to Python, but not half bad. Moya's template system is about 10-25% faster than Django templates with a similar feature set. There are a two main steps in rendering a template. First the template needs to be tokenized, i.e. split up in a data structure of text / tags. This … -
A simple method for rendering templates with Python
I never intended to write a template system for Moya. Originally, I was going to offer a plugin system to use any template format you wish, with Jinja as the default. Jinja was certainly up to the task; it is blindingly fast, with a comfortable Django-like syntax. But it was never going to work exactly how I wanted it to, and since I don't have to be pragmatic on my hobby projects, I decided to re-invent the wheel. Because otherwise, how do we get better wheels? The challenge of writing a template language, I discovered, was keeping the code manageable. If you want to make it both flexible and fast, it can quickly descend in to a mass of special cases and compromises. After a few aborted attempts, I worked out a system that was both flexible and reasonable fast. Not as fast as template systems that compile directly in to Python, but not half bad. Moya's template system is about 10-25% faster than Django templates with a similar feature set. There are a two main steps in rendering a template. First the template needs to be tokenized, i.e. split up in a data structure of text / tags. This … -
Don't import (too much) in your django settings
One of our production Django sites broke this afternoon with a database error "relation xyz doesn't exist". So: a missing table. Why 1 I helped debugging it and eventually found the cause by doing a select * from south_migrationhistory. This lists the south migrations and lo and behold, a migration had just been applied 25 minutes earlier. The migration name suggested a rename of tables, which of course matches the "missing table" error. Why 2 Cause found. But you have to ask yourself "why" again. So: "why was this migration applied?". Well, someone was working on a bit of database cleanup and refactoring. Naming consistency, proper use of permissions, that sort of thing. Of course, locally in a branch. And on a development database. Now why did the local command result in a migration on the production database? Why 3 So, effectively, "why don't the development settings work as intended"? We normally use settings.py as the production settings and a developmentsettings.py that is used in development. It imports from settings.py and sets the debug mode and development database and so. This project is a bit different in that there's only a settings.py. It does however try to import localsettings.py. This … -
Setup Django on Mac
I took some notes as I set-up Django and Python on a new Macbook running MacOS Yosemite (10.10). By following these steps, you'll have the best tools available - as far as I know - to code some Django apps. For most required applications you can use PIP, MacPorts, Python sources, etc. As a result, you might end-up with a massive mess ! To avoid any issue, I'm using PIP & VirtualEnv so I can easily manage multiple Django projects. To do so, the easiest is to get started with Brew. -
Haystack & Tastypie Orgs
Haystack & Tastypie Orgs -
How to Find the Performance Bottlenecks in Your Django Views?
Once you have your Django projects running, you come to situations, when you need to optimize for performance. The rule of thumb is to find the bottlenecks and then to take action to eliminate them by more idiomatic Python code, database denormalization, caching, or other techniques. What is a bottleneck? Literally it refers to the top narrow part of a bottle. In engineering, bottleneck is a case where the performance or capacity of an entire system is limited by a single or small number of components or resources. How to find these parts of your code? The most trivial way is to check the current time before specific code execution and after that code execution, and then count the time difference: from datetime import datetimestart = datetime.now()# heavy execution ...end = datetime.now()d = end - start # datetime.timedelta objectprint d.total_seconds() # prints something like 7.861985 However, measuring code performance for Django projects like this is inefficient, because you need a lot of such wrappers for your code until you find which part is the most critical. Also you need a lot of manual computation to find the critical parts. Recently I found line_profiler module that can inspect the performance of … -
Account Control part 1
This is the first in a series of videos on creating a site which utilizes other services to help your users stay informed. We start the series with getting our users setup with an account, and giving them the ability to log in and out.Watch Now... -
Astro Code School Tapped to Teach App Development at UNC Journalism School
Our own Caleb Smith, Astro Code School lead instructor, is teaching this semester at UNC’s School of Journalism, one of the nation’s leading journalism schools. He’s sharing his enthusiasm for Django application development with undergraduate and graduate media students in a 500-level course, Advanced Interactive Development. For additional details about the course and why UNC School of Journalism selected Caktus and Astro Code School, please see our press release. -
Astro Code School Tapped to Teach App Development at UNC Journalism School
Our own Caleb Smith, Astro Code School lead instructor, is teaching this semester at UNC’s School of Journalism, one of the nation’s leading journalism schools. He’s sharing his enthusiasm for Django application development with undergraduate and graduate media students in a 500-level course, Advanced Interactive Development. For additional details about the course and why UNC School of Journalism selected Caktus and Astro Code School, please see our press release. -
Solinea is looking for a Senior Backend Engineer (Python, Django, Elasticsearch)
This is my second week at Solinea, and I’m loving it! A position just opened up on our development team for a backend developer, and I wanted to share the love. :-) The company supports remote employees. Its headquarters is in Berkeley, CA, and I’m in Seattle, and I feel more connected now than, well, I did at some other companies I’ve worked for. If you’re in Seattle, I’d be happy to meet for coffee to talk at length about the job. To apply for this job, you can contact me at john@seeknuance.com, or click the “Apply for this position” button at the bottom of the job’s Recruiterbox page. Senior Backend Engineer (Python, Django, Elasticsearch) Location Berkeley, CA, US, or remote This position is only open to candidates based in and eligible to work in the United States. Responsibilities As a backend developer at Solinea, you will be primarily working on our flagship product from the API back, as well as committing to the OpenStack codebase. You will work in a sprint-based agile development team, and will participate in the full cycle including release/sprint planning, feature design, story definition, daily standups, development, testing, code review, and release packaging. You will … -
Reading/writing 3D STL files with numpy-stl
As a followup of my earlier article about reading and writing STL files with Numpy, I’ve created a library that can be used easily to read, modify and write STL files in both binary and ascii format. The library automatically detects whether your file is in ascii or binary STL format and is very fast due to all operations being done by numpy. First, install using pip or easy_install: pip install numpy-stl # Or if you don't have pip available easy_install numpy-stl Note that numpy numpy and python-utils version 1.6 or greater are required. While these should both be installed automatically by pip/easy_install, for numpy it’s generally recommended to download a binary release so it installs a bit faster. Example usage: https://github.com/WoLpH/numpy-stl from stl import stl mesh = stl.StlMesh('some_file.stl') # The mesh normals (calculated automatically) mesh.normals # The mesh vectors mesh.v0, mesh.v1, mesh.v2 # Accessing individual points (concatenation of v0, v1 and v2 in triplets) mesh.points[0] == mesh.v0[0] mesh.points[1] == mesh.v1[0] mesh.points[2] == mesh.v2[0] mesh.points[3] == mesh.v0[1] mesh.save('new_stl_file.stl') Documentation can be found here: http://numpy-stl.readthedocs.org/en/latest/ Please let me know if you have any problems using it or just to tell me that you like the project Link to this post! -
Django Logging Configuration: How the Default Settings Interfere with Yours
My colleague Vinod recently found the answer on Stack Overflow to something that's been bugging me for a long time - why do my Django logging configurations so often not do what I think they should? Short answer If you want your logging configuration to behave sensibly, set LOGGING_CONFIG to None in your Django settings, and do the logging configuration from scratch using the Python APIs: LOGGING_CONFIG = None LOGGING = {...} # whatever you want import logging.config logging.config.dictConfig(LOGGING) Explanation The kernel of the explanation is in this Stack Overflow answer by jcotton; kudoes to jcotton for the answer: before processing your settings, Django establishes a default configuration for Python's logging system, but you can't override it the way you would think, because disable_existing_loggers doesn't work quite the way the Django documentation implies. The Django documentation for disable_existing_loggers in 1.6, 1.7, and dev (as of January 8, 2015) says "If the disable_existing_loggers key in the LOGGING dictConfig is set to True (which is the default) the default configuration is completely overridden." (emphasis added) That made me think that I could set disable_existing_loggers to True (or leave it out) and Django's previously established default configuration would have no effect. Unfortunately, that's … -
Django Logging Configuration: How the Default Settings Interfere with Yours
My colleague Vinod recently found the answer on Stack Overflow to something that's been bugging me for a long time - why do my Django logging configurations so often not do what I think they should? Short answer If you want your logging configuration to behave sensibly, set LOGGING_CONFIG to None in your Django settings, and do the logging configuration from scratch using the Python APIs: LOGGING_CONFIG = None LOGGING = {...} # whatever you want import logging.config logging.config.dictConfig(LOGGING) Explanation The kernel of the explanation is in this Stack Overflow answer by jcotton; kudos to jcotton for the answer: before processing your settings, Django establishes a default configuration for Python's logging system, but you can't override it the way you would think, because disable_existing_loggers doesn't work quite the way the Django documentation implies. The Django documentation for disable_existing_loggers in 1.6, 1.7, and dev (as of January 8, 2015) says "If the disable_existing_loggers key in the LOGGING dictConfig is set to True (which is the default) the default configuration is completely overridden." (emphasis added) That made me think that I could set disable_existing_loggers to True (or leave it out) and Django's previously established default configuration would have no effect. Unfortunately, that's … -
We’re launching a Django code school: Astro Code School
One of the best ways to grow the Django community is to have more high-quality Django developers. The good news is that we’ve seen sharply increasing demand for Django web applications. The challenge that we and many other firms face is that there’s much higher demand than there is supply: there aren’t enough high-quality Django developers. We’ve talked about this issue intensely internally and with our friends while at DjangoCon and PyCon. We decided that we can offer at least one solution: a new Django-focused code school. We’re pleased to announce the launch of Astro Code School in Spring 2015. Astro will be the first Django code school on the East Coast. Programs include private trainings and weekend, 3-week, and 12-week full-time courses. In addition to Django, students will learn Python (of course), HTML, CSS, and JavaScript. They will come away being able to build web applications. The shorter programs will be geared towards beginners. The longer program will are for those with previous programming experience. Astro will also provide on-site, private corporate training, another area we frequently get asked about. Astro will be a separate company under Caktus. To support Astro, we welcome Brian Russell, the new director of … -
We’re Launching a Django code school: Astro Code School
One of the best ways to grow the Django community is to have more high-quality Django developers. The good news is that we’ve seen sharply increasing demand for Django web applications. The challenge that we and many other firms face is that there’s much higher demand than there is supply: there aren’t enough high-quality Django developers. We’ve talked about this issue intensely internally and with our friends while at DjangoCon and PyCon. We decided that we can offer at least one solution: a new Django-focused code school. We’re pleased to announce the launch of Astro Code School in Spring 2015. Astro will be the first Django code school on the East Coast. Programs include private trainings and weekend, 3-week, and 12-week full-time courses. In addition to Django, students will learn Python (of course), HTML, CSS, and JavaScript. They will come away being able to build web applications. The shorter programs will be geared towards beginners. The longer program will are for those with previous programming experience. Astro will also provide on-site, private corporate training, another area we frequently get asked about. Astro will be a separate company under Caktus. To support Astro, we welcome Brian Russell, the new director of … -
Why I Love Technical Blogging
I love writing blog posts, and today I’m setting out to do something I’ve never tried before: write a blog post about writing blog posts. A big part of our mission at Caktus is to foster and help grow the Python and Django development communities, both locally and nationally. Part of how we’ve tried to accomplish this in the past is through hosting development sprints, sponsoring and attending conferences such as PyCon and DjangoCon, and building a knowledge base of common problems in Python and Django development in our blog. Many in the Django community first get to know Caktus through our blog, and it’s both gratifying and humbling when I meet someone at a conference and the person thanks me for a post Caktus wrote that helped him or her solve a technical problem at some point in the past. While I personally don’t do as much software development as I used to and hence no longer write as many technical posts, the Caktus blog and many others in the community continue as a constant source of inspiration and education to me. As software developers we are constantly trying to work ourselves out of a job, building tools that … -
Why I Love Technical Blogging
I love writing blog posts, and today I’m setting out to do something I’ve never tried before: write a blog post about writing blog posts. A big part of our mission at Caktus is to foster and help grow the Python and Django development communities, both locally and nationally. Part of how we’ve tried to accomplish this in the past is through hosting development sprints, sponsoring and attending conferences such as PyCon and DjangoCon, and building a knowledge base of common problems in Python and Django development in our blog. Many in the Django community first get to know Caktus through our blog, and it’s both gratifying and humbling when I meet someone at a conference and the person thanks me for a post Caktus wrote that helped him or her solve a technical problem at some point in the past. While I personally don’t do as much software development as I used to and hence no longer write as many technical posts, the Caktus blog and many others in the community continue as a constant source of inspiration and education to me. As software developers we are constantly trying to work ourselves out of a job, building tools that … -
Why you should donate to the Django fellowship program
Disclaimer: I do not represent the Django Software Foundation in any way, nor has anything below been endorsed by the DSF. The following opinions are my own, unsolicited rambling. If you hadn’t been looking for it specifically, you may have missed it. The Django Softare Foundation is running a fundraising effort for the new Django Fellowship program. It sounds like they’re still trying to figure out how to get the word out, so I wanted to do what I could to tell you why you should chip in. This particular blog post is going to focus on encouraging (peer-pressuring) commercial Django users in particular, though enthusiasts are welcome to read along! Humble beginnings Django is free and open source. Just provide the expertise and the infrastructure and you can build just about whatever web powered contraption you’d like. So you end up doing just that. Your first stop is the Django tutorial, written and maintained by a community of volunteers (just like the rest framework itself). You stumble along, slowly at first. Perhaps you find yourself frustrated at times, or maybe things move along at a faster pace. In no time, you’ve got "Hello World!" rendering, and here comes a business idea! One hundred lines of … -
Caktus is looking for a Web Design Director
Over the last two years Caktus’ design portfolio has rapidly been growing. We’ve taken on new projects primarily focused on design and have received community recognition for those efforts. We are happy to have grown our design capabilities to match the level of quality we demand from our Django developers. We have found it’s important to have strength on both sides of the table as each side challenges the other and forces the final product of our process to be as high quality as possible. In an effort to continue to push ourselves and expand our web design skill sets, Caktus is looking to hire a new Web Design Director. We’re searching for someone who can do a bit of wireframing and user experience and then has the tools necessary to design and code pages. We’re looking for someone who is attune to both form and function and knows where to focus depending on clients’ needs. Caktus is committed to doing good in our development communities as well as through the projects that we choose to work on, so we are also interested in finding someone who is engaged in the design community. If you or someone you know would … -
Caktus is looking for a Web Design Director
Over the last two years Caktus’ design portfolio has rapidly been growing. We’ve taken on new projects primarily focused on design and have received community recognition for those efforts. We are happy to have grown our design capabilities to match the level of quality we demand from our Django developers. We have found it’s important to have strength on both sides of the table as each side challenges the other and forces the final product of our process to be as high quality as possible. In an effort to continue to push ourselves and expand our web design skill sets, Caktus is looking to hire a new Web Design Director. We’re searching for someone who can do a bit of wireframing and user experience and then has the tools necessary to design and code pages. We’re looking for someone who is attune to both form and function and knows where to focus depending on clients’ needs. Caktus is committed to doing good in our development communities as well as through the projects that we choose to work on, so we are also interested in finding someone who is engaged in the design community. If you or someone you know would … -
Introducing High Performance Django Expert Sessions
With the launch of our book, High Performance Django, we’ve received a number of inquiries from people asking for advice, for which the answers are too specific to their application to give good general advice, and too short to sign a consulting engagement. Rather than decline to help, we now offer Expert Sessions - a one-hour online consultation with a member (or members) of the Lincoln Loop team. Schedule an Expert Session and we'll meet up with you via Google Hangouts, Skype, or phone to answer any questions or provide expertise on building and scaling your complex Django application. In the past, we've answered such questions as: What technologies should we use for building a complex, high-performance application? Our app is super complex and it takes us 3 days to onboard a new developer. How can we simplify things to speed up onboarding? Should we move our infrastructure to Amazon Web Services or Heroku? What are the benefits and how do we perform the correct analysis? How can we make our deploys more reliable? How do we move from our legacy system to Django in order to improve reliability and cut costs? Should we use MongoDB or Redis? How do …