Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
How To Create Installable Django Packages
What I mean by an "installable Django package": a reusable component that can be shared across Django projects, allowing us to combine our own efforts with others. Some examples include: django-test-plus django-crispy-forms dj-stripe dj-spam Ever want to quickly create a similarly installable Django package to submit to PyPI and Django Packages? One that goes beyond the basics described in the Django tutorial? Specifically, a package that includes: Test runner so you don't need a example/test project (Although those can be useful). The important configuration in place: Travis, editorconfig, gitignore, etc. The important documentation in place: Readme, License, Read the Docs-ready Sphinx docs, etc. Static files ready to go. A base DTL/Jinja2 template ready to go. All those other fiddly bits not included in django-admin.py startapp that are hard to remember. Well, here's how I do it. Introducing cookiecutter-djangopackage First, get Cookiecutter. Trust me, it's awesome: $ pip install cookiecutter Now run it against this repo: $ cookiecutter https://github.com/pydanny/cookiecutter-djangopackage.git You'll be prompted to enter some values. Enter them. Then an installable Django package will be built for you. Warning: app_name must be a valid Python module name or you will have issues on imports. Enter the new package (in my case, … -
How To Create Installable, Reusable Django Packages
What I mean by an "installable Django package": a reusable component that can be shared across Django projects, allowing us to combine our own efforts with others. Some examples include: django-test-plus django-crispy-forms dj-stripe dj-spam Ever want to quickly create a similarly installable Django package to submit to PyPI and Django Packages? One that goes beyond the basics described in the Django tutorial? Specifically, a package that includes: Test runner so you don't need a example/test project (Although those can be useful). The important configuration in place: Travis, editorconfig, gitignore, etc. The important documentation in place: Readme, License, Read the Docs-ready Sphinx docs, etc. Static files ready to go. A base DTL/Jinja2 template ready to go. All those other fiddly bits not included in django-admin.py startapp that are hard to remember. Well, here's how I do it. Introducing cookiecutter-djangopackage cookiecutter-djangopackage is a Cookiecutter template for creating reusable Django packages. Using it is easy: First, get Cookiecutter. Trust me, it's awesome: $ pip install cookiecutter Now run it against this repo: $ cookiecutter https://github.com/pydanny/cookiecutter-djangopackage.git You'll be prompted to enter some values. Enter them. Then an installable Django package will be built for you. Warning: app_name must be a valid Python module name … -
How To Create Installable, Reusable Django Packages
name : Django Package Ecosystem: cookiecutter-djangopackage align : center alt : Django Package Ecosystem: cookiecutter-djangopackage target : https://www.pydanny.com/how-to-create-installable-django-packages.html What I mean by an \"installable Django package\": a reusable component that can be shared across Django projects, allowing us to combine our own efforts with others. Some examples include: django-test-plus django-crispy-forms dj-stripe dj-spam Ever want to quickly create a similarly installable Django package to submit to PyPI and Django Packages? One that goes beyond the basics described in the Django tutorial? Specifically, a package that includes: Test runner so you don't need a example/test project (Although those can be useful). The important configuration in place: Travis, editorconfig, gitignore, etc. The important documentation in place: Readme, License, Read the Docs-ready Sphinx docs, etc. Static files ready to go. A base DTL/Jinja2 template ready to go. All those other fiddly bits not included in django-admin.py startapp that are hard to remember. Well, here's how I do it. Introducing cookiecutter-djangopackage cookiecutter-djangopackage is a Cookiecutter template for creating reusable Django packages. Using it is easy: First, get Cookiecutter. Trust me, it's awesome: $ pip install cookiecutter Now run it against this repo: $ cookiecutter https://github.com/pydanny/cookiecutter-djangopackage.git You'll be prompted to enter some values. Enter them. Then … -
Installing Wagtail
Wagtail has become a very popular CMS in the last year. Start with this video to see how to get it up and running for your project, and get content on the homepage.Watch Now... -
Introducing Moya Techblog, a Blogging Engine for Coders and Photographers
I've had a blog on my vanity domain for nearly a decade now. For the last 6 years, it has been powered by Django Techblog, which I wrote out of my frustration with syntax highlighting plugins in Wordpress. Techblog has happily served my blog those 6 years, with only minor hiccups when I half-heartedly ported the code to the latest Django. There was nothing terribly wrong with Django Techblog; it had multiple blogs, tags, search etc., but there were some annoyances that I didn't have the motivation to do much about. The custom markup system I used was clever, but I would often forget the syntax! The support for images was rudimentary and the single-threaded comment system wouldn't notify me of replies. So fast forward 6 years and the time is right to build a new blog system to fix the old niggles. This time around I had same requirements for syntax highlighting in both posts and comments, with a new requirement to be able to manage and display photographs, while supporting the same multi-blog and feed URLs. Moya Tech Blog The new blog engine running my blog is Moya Tech Blog. Posts and comments use markdown (by default), which … -
Nginx proxying to nginx: getting gzip compression to work
At work we use gunicorn as our wsgi runner. Like many, gunicorn advises you to run the nginx webserver in front of it. So on every server we have one or more websites with gunicorn. And an nginx in front. Nginx takes care, of course, of serving the static files like css and javascript. Some gzipping of the results is a very, very good idea: server { listen 80; server_name my.great.site; ... gzip on; gzip_proxied any; gzip_types text/css text/javascript text/xml text/plain application/javascript application/x-javascript application/json; .... } Two notes: The default is to only gzip html output. We also want javascript and json. So you need to configure gzip_types. (I copy-pasted this from one of my config files, apparently I needed three different javascript mimetypes... Perhaps some further research could strip that number down.) gzip_proxied any tells nginx that gzipping is fine even for proxied requests. Proxied requests? Yes, because we have a lot of servers and all external traffic first hits our main nginx proxy. So: we have one central server with nginx that proxies requests to the actual servers. So: nginx behind nginx: server { listen 443; server_name my.great.site; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect … -
Looking for an experienced Python Developer
My client, WildFoundry, is looking for an experienced Python developer to join us. We work in the field of IoT, and you will get to work with a variety of really cool technologies. Here's the job description: Job Description WildFoundry is seeking a senior Python web application developer on a 8 month contract to help us in the development of the dataplicity Internet-of-Things platform (dataplicity.com). You would be expected to work from your home or own office most of the time and very high quality candidates based in Slovakia, Poland and the United Kingdom will be considered. This is an unbeatable opportunity to work from home, earn excellent rates and join in with fast growing projects. Our web application runs on a combination of Python and django, and we’re really pushing the boundaries of what we can do with both of them. You will be challenged. You’ll be playing with everything from Amazon and Linode services to embedded PCs, and a bunch of new web technologies. You’ll be writing daemons, UI for django apps, code for embedded systems, websockets. We are seeking a top calibre developer well regarded in the community. If you’ve contributed code to OSS apps or have … -
Buildout 2.5.0 has much nicer version conflict reporting
We use buildout for all our django projects. Nothing wrong with pip, but buildout has extension possibilities build-in (for creating directories, installing user crontabs, local development checkouts and many more) that are quite helpful. And it works better when you need to use system packages (gdal, mapnik, etc). One area where buildout could use some improvement was the version conflict reporting. Let's say you have pinned django to 1.6.6 (old project that I'll upgrade to 1.8 this week) and you add the django debug toolbar. This is the error you get: The constraint, 1.6.6, is not consistent with the requirement, 'Django>=1.7'. While: Updating django. Error: Bad constraint 1.6.6 Django>=1.7 First things first. An easy one is to improve the wording of the message: While: Installing django. Error: The requirement ('Django>=1.7') is not allowed by your [versions] constraint (1.6.6) Now... so there is some package that requires at least django 1.7. But which one? Buildout did not tell you. Which would mean you'd have to grep in all your requirements' sub-requirements for which package actually requires the offending "django>=1.7"... I've now added some internal logging that stores which package required which dependency. After an error occurs, the list is searched for … -
Ember application structure
Ember.js applications are divided into multiple files and folders. All of which makes sense when we get to know what is where, so lets take a look on Ember application structure. -
Setting up ember-cli development environment with ember 2.1
In a series of tutorials starting with this one I'll try to showcase ember.js framework for building fronted web applications. As a backend there will be Django Rest Frameowork and more. As times change and JavaScript frameworks don't just download to your static folder I'll start with setting up Ember.js development environment with ember-cli. -
We need less powerful languages
Many systems boast of being ‘powerful’, and it sounds difficult to argue that this is a bad thing. Almost everyone who uses the word assumes that it is always a good thing. The thesis of this post is that in many cases we need less powerful languages and systems. Before I get going, I should say first of all that very little in this post is original. The train of thought behind it was set off by reading Hofstadter's book Gödel, Escher, Bach — an Eternal Golden Braid which helped me pull together various things in my own thinking where I've seen the principle in action. Philip Wadler's post on the rule of least power was also formative, and most of all I've also taken a lot from the content of this video from a Scala conference about everything that is wrong with Scala, which makes the following fairly central point: Every increase in expressiveness brings an increased burden on all who care to understand the message. My aim is simply to illustrate this point using examples that might be more accessible to the Python community than the internals of a Scala compiler. I also need a word about definitions. … -
MIT uses Evennia!
Evennia was recently used as a test bed to train an AI system to attempt to play a MUD as a human would - by only reading and understanding the text on the screen. Researchers at MIT (Massachusetts Institute of Technology) recently presented the paper Language understanding for Text-based games using Deep reinforcement learning (PDF) at a conference on natural language processing. A summary is in the MIT press release.I was contacted by these fine folks some time ago so I knew they had plans to use Evennia for their research. It's great to see they now have an article out on it! Evennia devs are also mentioned in the acknowledgements - so something for the Evennia dev community to be proud of! MUDs are tricky The main complication for an AI playing a MUD is that the computer has no access to the actual game state but must try to surmise how well it's doing only from the text given (same as a human would). The researchers compare the results from a range of deep-learning neural network algorithm that they train to play. To test their AI, the researchers first used Evennia to build a simple training "Home World": … -
How to send Jabber (XMPP) messages from Django
Did you ever want to have a simple Django notification bot? An intranet one which just sends you (or someone you tell it to) Jabber messages when certain events occur? So did I. Please, welcome: django-jabber. -
How to send Jabber (XMPP) messages from Django
Did you ever want to have a simple Django notification bot? An intranet one which just sends you (or someone you tell it to) Jabber messages when certain events occur? So did I. Please, welcome: django-jabber. -
Tip: How to get a single object`s value with Django ORM
There are times when you want to get a single field of a single object in the database. For example, just get the headline of the blog post #1, not fetching it’s body. How do you do it in a usual way? >>> BlogPost.objects.only('headline').get(pk=1).headline 'Hello world' # Or maybe even this way: >>> BlogPost.objects.values('headline').filter(pk=1)[0]['headline'] 'Hello world' Recently I’ve stumbled upon a shorter one: -
Tip: How to get a single object`s value with Django ORM
There are times when you want to get a single field of a single object in the database. For example, just get the headline of the blog post #1, not fetching it’s body. How do you do it in a usual way? >>> BlogPost.objects.only('headline').get(pk=1).headline 'Hello world' # Or maybe even this way: >>> BlogPost.objects.values('headline').filter(pk=1)[0]['headline'] 'Hello world' Recently I’ve stumbled upon a shorter one: -
When you shouldn’t use the Django admin
In case you’ve thought I detest django.contrib.admin — by no means. Actually it’s one of the Django’s greatest features, I really love it. In most cases. Here’s a real life story. We’ve had to quickly put up the first version of an intranet claim tracking system, and one of our developers was just crazy about the Django admin… So why not, we’ve got along with the stock interface as the primary one for ... -
When you shouldn’t use the Django admin
In case you’ve thought I detest django.contrib.admin — by no means. Actually it’s one of the Django’s greatest features, I really love it. In most cases. Here’s a real life story. We’ve had to quickly put up the first version of an intranet claim tracking system, and one of our developers was just crazy about the Django admin… So why not, we’ve got along with the stock interface as the primary one for ... -
A Quick Introduction to Backbone
Who Uses Backbone? airbnb, newsblur, disqus, hulu, basecamp, stripe, irccloud, trello, … Why? http://backbonejs.org/#FAQ-why-backbone It is not a framework Backbone is an MVP (Model View Presenter) javascript library that, unlike Django, is extremely light in its use of conventions. Frameworks are commonly seen as fully-working applications that run your code, as opposed to libraries, where you import their code and run it yourself. Backbone falls solidly into the latter category and it’s only through the use of the Router class that it starts to take some control back. Also included are View, Model and Collection (of Models), and Events, all of which can be used as completely standalone components and often are used this way alongside other frameworks. This means that if you use backbone, you will have much more flexibility for creating something unusual and being master of your project’s destiny, but on the other hand you’ll be faced with writing a lot of the glue code yourself, as well as forming many of the conventions. Dependencies Backbone is built upon jQuery and underscore. While these two libraries have some overlap, they mostly perform separate functions; jQuery is a DOM manipulation tool that handles the abstractions of various browser … -
Initial Data in Django
I’ve struggled to find an ideal way to load initial data for Django projects. By “initial data,” I’m referring to the kind of data that you need on a new system for it to be functional, but could change later. These are largely lists of possible choices, such as time zones, countries, or crayon colors. -
Speeding up a Django web site without touching the code
I’ve recently been tweaking my server setup for a Django 1.3 web site with the goal of making it a bit faster. Of course, there is a lot of speed to gain by improving e.g. the number of database queries needed to render a web page, but the server setup also has an effect on the web site performance. This is a log of my findings. All measurements have been done using the ab tool from Apache using the arguments -n 200 -c 20, which means that each case have been tested with 20 concurrent requests up to 200 requests in total. The tests was run from another machine than the web server, with around 45ms RTT to the server. This is not a scientific measurement, but good enough to let me quickly test my assumptions on what increases or decreases performance. The Django app isn’t particularly optimized in itself, so I don’t care much about the low number of requests per second (req/s) that it manages to process. The main point here is the relative improvement with each change to the server setup. The baseline setup is a Linode 1024 VPS (Referral link: I get USD 20 off my … -
Comics v2.2.0 released with Django 1.5 support
Version 2.2.0 of my comics aggregator is now released. It features a general upgrade of dependencies, including the move from Django 1.4 to Django 1.5, and a lot of updates to comic crawlers. The Django upgrade was completed months ago and it’s been running my Comics instance since, so it’s about time to get it released before Django 1.6 arrives in a month or two. Regarding the crawler updates, it’s a bit sad to see that many of the crawlers have been broken for months without me or anybody else noticing, but it’s hard to catch some content lacking in the middle of a firehose of similar content. I guess I’ll have to make it a monthly task to look through the crawler status page of my Comics instance and do patch releases with updated crawlers. Check out the project docs for more information about Comics and this release in particular. -
Comics v2.3.0 released with better mobile support
Version 2.3.0 of my comics aggregator is now released. As always, dependencies have been updated, including the routine Django upgrade from Django 1.5 to 1.6, just in time for the upcoming 1.7 release. The largest change this time around is the move from Bootstrap 2 to 3, which includes a refreshed, flatter design and lots of tweaking to make Comics both look good and work nicely on mobile devices, something it didn’t use to do. The dependency overview at requires.io has been a great motivation for doing some maintenance work on Comics. The only dependency left outdated is django-registration, as 1.0 moves to class-based views, which requires some larger changes to my customizations. Thus, the upgrade of django-registration has been deferred together with the related upgrade of my vendorized copy of django-invitation. Most, if not all, of the other dependencies seems to support Python 3 now, though some lack the right Trove classifiers in their PyPI registration, so they are not correctly labeled by requires.io. I found an open pull request for cssmin and a recent commit for django-compressor adding the missing Trove classifiers. I’ve also done my part to improve the Python 3 metadata by sending a pull request … -
Comics v2.2.0 released with Django 1.5 support
Version 2.2.0 of my comics aggregator is now released. It features a general upgrade of dependencies, including the move from Django 1.4 to Django 1.5, and a lot of updates to comic crawlers. The Django upgrade was completed months ago and it’s been running my Comics instance since, so it’s about time to get it released before Django 1.6 arrives in a month or two. Regarding the crawler updates, it’s a bit sad to see that many of the crawlers have been broken for months without me or anybody else noticing, but it’s hard to catch some content lacking in the middle of a firehose of similar content. I guess I’ll have to make it a monthly task to look through the crawler status page of my Comics instance and do patch releases with updated crawlers. Check out the project docs for more information about Comics and this release in particular. -
Comics v2.3.0 released with better mobile support
Version 2.3.0 of my comics aggregator is now released. As always, dependencies have been updated, including the routine Django upgrade from Django 1.5 to 1.6, just in time for the upcoming 1.7 release. The largest change this time around is the move from Bootstrap 2 to 3, which includes a refreshed, flatter design and lots of tweaking to make Comics both look good and work nicely on mobile devices, something it didn’t use to do. The dependency overview at requires.io has been a great motivation for doing some maintenance work on Comics. The only dependency left outdated is django-registration, as 1.0 moves to class-based views, which requires some larger changes to my customizations. Thus, the upgrade of django-registration has been deferred together with the related upgrade of my vendorized copy of django-invitation. Most, if not all, of the other dependencies seems to support Python 3 now, though some lack the right Trove classifiers in their PyPI registration, so they are not correctly labeled by requires.io. I found an open pull request for cssmin and a recent commit for django-compressor adding the missing Trove classifiers. I’ve also done my part to improve the Python 3 metadata by sending a pull request …