Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Personal lessons from XOXO
Three things I want to remember from XOXO, written in haste as the conference wraps up: Optimism XOXO is so un-snarky, so radically honest and sincere, that it almost feels like another world. XOXO is an amazing departure from that. The sincerity and friendliness is so total, so comfortable. A number of speakers shared intensely personal moments: Marco called his talk a “group therapy session” and discussed his fear and insecurity; Cabel shared a story of depression that was heartfelt and resonant. -
How to Create a File Upload Widget
Ajaxified file uploads are becoming de facto standard on the web. People want to see what they chose right after selecting a file instead of during submit of the form. Also if a form has validation errors, nobody wants to select the files again; the selection made should be still available in the form. Therefore, we need a solution that works by Ajax. Luckily there is a Django app that can help. It's called django-ajax-uploader. Ajax uploader allows to create asynchronous single and multiple file uploads. All uploads are done into the uploads directory. In addition to the default functionality we need a possibility to show the preview of the temporary uploaded file, translate all messages and buttons, delete a file, move a file to a specific directory. I created a demo project which implements all that. If you have a ModelForm with a FileField or ImageField, you need to not show this field in the form, but instead to add a hidden field for uploaded file path. When you choose a file, it will be uploaded to a temporary uploads directory and its path will be set in the hidden field. Also you need a hidden BooleanField for the … -
First thoughts about Django-CMS
I just set up a site using Django-CMS over at Pomme d'Api Preschool. Overall, I am pretty impressed. I really like the Django admin interface enhancements as well as the site overlay editing feature. One of the best things it he use of django-filer, a file management tool to manage all the uploads to the site. It's awesome and it makes me want to throw out this home page completely and switch over to Django-CMS. Image handling in Drupal has always sucked and still does. The fact that there was no official media/image handling in Drupal 6 sucks, and it's made worse by the fact that there is no real upgrade path to Drupal 7 for media/images, especially if you're like me and you used the "Image" and "image-assist" modules, two of the most popular modules dealing with images. Django-CMS is pretty powerful and so far it has allowed me to do pretty much anything I have wanted to do. -
Central logging in Django with Graylog2 and graypy
.. |--| unicode:: U+2013 .. en dash .. |---| unicode:: U+2014 .. em dash, trimming surrounding whitespace :trim: Django's `logging configuration `_ facilities, which arrived in version 1.3, have greatly eased (and standardized) the process of configuring logging for Django projects. When building complex and interactive web applications at Caktus, we've found that detailed (and properly configured!) logs are key to successful and efficient debugging. Another step in that process |---| which can be particularly useful in environments where you have multiple web servers |---| is setting up a centralized logging server to receive all your logs and make them available through an easily accessible web interface. There are a number useful tools to do this, but one we've found that works quite well is `Graylog2 `_. Installing and configuring Graylog2 is outside the scope of this post, but there are plenty of tutorials on how to do so accessible through your search engine of choice. Once you have it setup, getting logs flowing to Graylog2 from Django is relatively straightforward. First, grab a copy of the ``graypy`` package from PyPI and add it to your requirements file:: pip install -U graypy Next, add the following configuration inside the ``LOGGING['handlers']`` … -
Django Round-Up #10
This week we're joined by Portia Burton! We discuss Portland, Mozilla Persona, making a game board, migrations and South's frozen ORM, Bee Ware and GUI tools vs. the command line, clever comprehensions, and a whole lot more. -
crispy-forms
Learn how to get started using the popular crispy forms django application to streamline rendering your templates by doing your layout in python.Watch Now... -
Django Round-Up #9
Miguel Grinberg joins us for a very Python and Flask centered episode where we discuss color themes, video processing, web scraping, class-based views, and learning Flask. -
Wedding hacks - seating planner using simulated annealing
This is the third in a seris of posts in which my upcoming wedding has exercised my programming skills. The problem There are a lot of ways to seat approx 130 guests in tables of 10. (Digression: how many ways? There n! ways to order a list of n people. We then group that list of n people into j groups (tables) of size k each (assuming an exact division is possible for simplicity). In each group, there are k! different ways to order the people, but all these are considered equivalent for our purposes. So we divide by k!, and do it j times, once for each table. We could then shuffle all the groups, and all the results of such shuffling are also considered equivalent. So we divide by j! to count for these permutations. So, I make it: n!/(j*k!*j!) Or, in my case: 22, 014, 379, 788, 144, 009, 262, 986, 489, 297, 967, 619, 407, 616, 773, 070, 962, 391, 042, 003, 562, 758, 124, 860, 965, 657, 753, 242, 386, 208, 110, 081, 303, 218, 233, 306, 048, 808, 531, 260, 440, 119, 599, 226, 289, 816, 251, 326, 745, 993, 359, 038, 728, 297, … -
Wedding hacks - John Lewis gift list hyperlink
I'm getting married in 3 weeks time - yay! But this post isn't about that — it's a quick programming-and-wedding-related tip. We set up a John Lewis gift list, but we found the web site's instructions for use could be improved. The instructions to pass on to potential givers were: Go to this site Type in this gift list number That's fine for printed instructions, but if you already have a website, there is this magical thing called a hyperlink which should be able to take you straight there, without any error prone typing etc. John Lewis didn't provide any instructions for doing this, and as the number never appears in a URL, even after this point, it isn't obvious that there is a way to do it. However, I managed to impress my fiancée with my leet hacking skills to get around this. OK, so I right clicked at an appropriate place, chose “Inspect element”, applied some knowledge of web development and made a few easy guesses. I came up with the following URL which works, and will take you straight to your gift list: https://www.johnlewisgiftlist.com/giftint/guestpassword?giftListNumber=YOURNUMBER Just replace YOURNUMBER with your actual number. That's all for now - but … -
Personafied
Reminder for people who try and think it’s a bug: Persona, on this site, is for me to be able to log in and post entries. As such, you will not be able to log in to this site, since you don’t have an account and can’t create one. This isn’t a bug, it’s intended functionality — site owners can control whether accounts can be created, and by whom. So, last ... Read full entry -
Personafied
Reminder for people who try and think it’s a bug: Persona, on this site, is for me to be able to log in and post entries. As such, you will not be able to log in to this site, since you don’t have an account and can’t create one. This isn’t a bug, it’s intended functionality — site owners can control whether accounts can be created, and by whom. So, last week I mentioned in passing ... Read full entry -
I Hate Generic Foreign Keys, but this works anyway
I'm really not a fan of the concept of Generic Foreign Keys. They do have their place, and the app I've just started is a reasonable example. It's django-activity-streams, and I'm using it essentially as an audit stream. It stores the user who performed the change, the object that was changed, when it was changed, and a serialised version of the fields that have changed, in the format of: {% highlight js %} [ { "field": "date_of_birth", "old": "1955-01-10", "new": "1955-10-01" } ] {% endhighlight %} Now, the complication comes when trying to generate reports based on this stuff, and that is all down to the use of GFKs. Essentially, what I want to be able to do is: {% highlight python %} Action.objects.between(start, finish).verb('updated').filter( target__in=queryset ) {% endhighlight %} But this will not work, as there is no real `target` field: it's a GFK field. But we can query on the two fields that make it up: `target_content_type` and `target_object_id`. So, you might think we can do something like: {% highlight python %} ctype = ContentType.objects.get_for_model(queryset.model) Action.objects.filter( target_content_type=ctype, target_object_id__in=queryset ) {% endhighlight %} Alas, this will not work either, as `target_object_id` is a "character varying", and a queryset kind-of … -
Django Dash - Registration Soon! (And Sponsors Needed)
Django Dash - Registration Soon! (And Sponsors Needed) -
Django Round-Up #8
Lynn Root joins us to discuss the latest Django and Python links, running your own young coders class, and PRISMs effect on us and the technology we use. -
Caktus Participates in DjangoCon 2013
Caktus is happy to be involved in this year’s DjangoCon hosted in Chicago. We are pumped about the great lineup of speakers and can’t wait to see some of our old friends as well as meet some new folks. Beyond going to see the wonderful talks, Caktus is participating as a sponsor and Tobias McNulty will be speaking on scaling Django web apps. Come stop by our booth or see Tobias’ talk to connect with us. Tobias’ talk "Scaling Your Write-Heavy Django App: A Case Study" will delve into some Django related scaling challenges we encountered while developing a write-heavy web app that would be deployed to millions of students and parents in the Chicago public school system. Through the lens of these specific problems he will show widely applicable solutions to forecasting web app loads, scaling, and automating the configuration so that it is completely repeatable. We are proud to support the Django community through our sponsorship and involvement in DjangoCon. We’re all looking forward to the event and hope to see some of you there! -
Django redirects with regular expressions
Django redirects with regular expressions -
Django Round-Up: DjangoCon Edition
In this special episode, we interview Steve Holden and discuss the history of DjangoCon, what goes into producing a conference, and Steve's personal history with Django. -
Configuring various browsers for Selenium web applications tests
Selenium can test your web applications quite easily (at least the frontend). To perform the tests it launches a webdriver which in most cases will be Firefox. But what about other browsers that may interpret CSS/JS differently, or what about mobile browsers on mobile devices? Selenium does support them, but to get them working some extra configuration is required. In this article I'll show how to make other browsers work with Python Selenium client (on Linux). -
Activity Feed with Event Log
Adding an activity feed is simple with the eventlog application. I show you how to get started with it by easily adding it to your project, and how use and administer it.Watch Now... -
Join me in supporting the Ada Initiative
I believe deeply in the importance of gender equality, yet I work in open source, a community with shockingly few women. The Ada Initiative is working together with people like me to bring more women into open source - and we’re succeeding. That’s why I’m challenging the Python community to help me raise $10,000: I’ll match any donations from the Python community to the Ada Initiative up to a maximum of $5,000. -
Django Round-Up #7
This week Kenneth and Brandon are joined by Julia Elman! -
Catching up
For a while now I’ve been pretty embarrassed by this site. Not by the visual design, or the functionality (though some bits have been lost along the way, for reasons that will become obvious in a moment), but by the fact that it was old. As in, over five years old. It was running on a bunch of ancient code that I’d written a long, long time ago, on an ancient Subversion checkout ... Read full entry -
Catching up
For a while now I’ve been pretty embarrassed by this site. Not by the visual design, or the functionality (though some bits have been lost along the way, for reasons that will become obvious in a moment), but by the fact that it was old. As in, over five years old. It was running on a bunch of ancient code that I’d written a long, long time ago, on an ancient Subversion checkout of Django ... Read full entry -
Django and pip wheel
Just a quick heads-up: older Django versions don't work properly if installed via wheel. It's fixed in 1.6 but it's not final yet (right now it's in beta). Edit: Django 1.5.2 has the fix backported from 1.6. Apparently the older versions of Django list the package data files under the data_files setup.py option and wheel follows the spec to the letter (installs data_files in sys.prefix) while setuptools does not (it treats relative data_files just like package_data entries). If you switched to wheels already you can fix the template loading with something like this: import sys import os from django.template.base import TemplateDoesNotExist from django.template.loader import BaseLoader from django.conf import settings class SysPrefixLoader(BaseLoader): is_usable = True def load_template_source(self, template_name, template_dirs=None): pkg_name = 'templates/' + template_name for app in settings.INSTALLED_APPS: try: return open( os.path.join( sys.prefix, os.path.join(*app.split('.')), pkg_name ), 'rb' ).read().decode(settings.FILE_CHARSET), 'sysprefix:%s:%s' % (app, pkg_name) except Exception: pass raise TemplateDoesNotExist(template_name) And just add module.SysPrefixLoader to TEMPLATE_LOADERS in the settings. For the staticfiles, use this finder: import sys import os from django.contrib.staticfiles.finders import AppDirectoriesFinder, FileSystemStorage class SysPrefixAppStaticStorage(FileSystemStorage): def __init__(self, app, *args, **kwargs): location = os.path.join( sys.prefix, os.path.join(*app.split('.')), 'static' ) super(SysPrefixAppStaticStorage, self).__init__(location, *args, **kwargs) class SysPrefixAppDirectoriesFinder(AppDirectoriesFinder): storage_class = SysPrefixAppStaticStorage And add module.SysPrefixAppDirectoriesFinder to STATICFILES_FINDERS in the … -
Django and pip wheel
Just a quick heads-up: older Django versions don't work properly if installed via wheel. It's fixed in 1.6 but it's not final yet (right now it's in beta). Edit: Django 1.5.2 has the fix backported from 1.6. Apparently the older versions of Django list the package data files under the data_files setup.py option and wheel follows the spec to the letter (installs data_files in sys.prefix) while setuptools does not (it treats relative data_files just like package_data entries). If you switched to wheels already you can fix the template loading with something like this: import sys import os from django.template.base import TemplateDoesNotExist from django.template.loader import BaseLoader from django.conf import settings class SysPrefixLoader(BaseLoader): is_usable = True def load_template_source(self, template_name, template_dirs=None): pkg_name = 'templates/' + template_name for app in settings.INSTALLED_APPS: try: return open( os.path.join( sys.prefix, os.path.join(*app.split('.')), pkg_name ), 'rb' ).read().decode(settings.FILE_CHARSET), 'sysprefix:%s:%s' % (app, pkg_name) except Exception: pass raise TemplateDoesNotExist(template_name) And just add module.SysPrefixLoader to TEMPLATE_LOADERS in the settings. For the staticfiles, use this finder: import sys import os from django import VERSION from django.contrib.staticfiles.finders import AppDirectoriesFinder, AppStaticStorage class SysPrefixStorage(AppStaticStorage): def __init__(self, app, *args, **kwargs): self.app_module = app if self.app_module == 'django.contrib.admin' and VERSION < (1, 4): self.prefix = 'admin' self.source_dir = 'media' location …