Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
virtualenv Lives!
Setting up Python to the point to be able install packages from PyPI can be annoying and time-intensive. Even worse are OS-provided installations that start throwing cryptic error messages. Especially desktops are prone to that but it’s possible to break the whole toolchain of a server by installing some shiny package you heard about on reddit. Your desktop system is unlikely to be a throwaway virtual machine or container. Which makes it a highly mutable system with difficult rollbacks and a lot of pain if stuff breaks1. So until we all run NixOS on our desktops: Don’t install anything into its global site-packages beyond virtualenv. Does that sound extreme to you? Only if you haven’t found the right tools to make it effortless. virtualenv in 2014‽ virtualenv has been around for a while and was a somewhat accepted standard for installing Python software. Sadly, there are many missionaries running around nowadays, boldly proclaiming the end of virtualenv. Mostly because of containers in general and usually because of docker in particular. I find that unfortunate and shortsighted. Frankly, they fail to see the whole picture: virtualenv’s job isn’t just to separate your projects from each other. Its job is also to … -
virtualenv Lives!
Setting up Python to the point to be able install packages from PyPI can be annoying and time-intensive. Even worse are OS-provided installations that start throwing cryptic error messages. Especially desktops are prone to that but it’s possible to break the whole toolchain of a server by installing some shiny package you heard about on reddit. Your desktop system is unlikely to be a throwaway virtual machine or container. Which makes it a highly mutable system with difficult rollbacks and a lot of pain if stuff breaks. So until we all run NixOS on our desktops: Don’t pip-install anything into its global site-packages beyond virtualenv. Does that sound extreme to you1? Only if you haven’t found the right tools to make it effortless. virtualenv in 2014‽ virtualenv has been around for a while and was a somewhat accepted standard for installing Python software. Sadly, there are many missionaries running around nowadays, boldly proclaiming the end of virtualenv. Mostly because of containers in general and usually because of docker in particular. I find that unfortunate and shortsighted. Frankly, they fail to see the whole picture: virtualenv’s job isn’t just to separate your projects from each other. Its job is also to … -
Long Live Adjacency Lists
I recently wrote about the excellent book [SQL Antipatterns](http://pragprog.com/book/bksqla/sql-antipatterns), and in it briefly discussed the tree structures. I've been thinking about trees in [Postgres](http://www.postgresql.org/) a fair bit lately, and a discussion on [#django](https://botbot.me/freenode/django/) gave me further incentive to revisit this topic. The book discusses four methods of storing a tree in a database. *Adjacency Lists*, apart from the inability to grab a full or partial tree easily, are the simplest to understand. The child object stores a reference to it's parent. Because this is a foreign key, then it always maintains referential integrity. Fetching a parent is simple, as is fetching all children, or siblings. It's only when you need to fetch an arbitrary depth that things become problematic, unless you use a recursive query. More on that later. Postgres has an extension called [ltree](http://www.postgresql.org/docs/9.3/static/ltree.html), which provides an implementation of a *Path Enumeration*, but one thing that really bothers me about this type of structure is the lack of referential integrity. In practice, I'm not sure what having this `ltree` structure would give you over simply storing the keys in an `ARRAY` type. Indeed, if Postgres ever gets Foreign Key constraints for ARRAY elements (which there is a patch floating … -
Django-ckeditor-updated and django-ckeditor merge
I've released a new version of django-ckeditor-updated covering all latest changes (full ckeditor 4.4.4 package and some inline editor fixes). The django-ckeditor-updated-4.4.4 can be installed from pypi. Note that there is now a new required configuration variable - CKEDITOR_JQUERY_URL. All outstanding commits have been pushed to django-ckeditor repository (from which I forked) and released as django-ckeditor-4.4.4 (4.4.5 for updated readme). If you are using the "updated" version you can now switch to the django-ckeditor as I plan to make changes there as I now can push pypi releases for it. django-ckeditor-updated is closed. -
Announcing BarCamp Django SF!
BarCamp Django SF! On October 4th and 5th BarCamp Django SF will be taking place in the Eventbrite office in San Francisco. BarCamp Django SF is a low-cost, community-focused event that's different than any previous multi-day Django conference. How is BarCamp Django SF different than previous Django conferences and events? Speakers are determined at the event I know what you are thinking. It's something on the line of "What the heck?!?" It means that if you want to give a talk, you don't need to be an expert. We don't have an formal, extensive review process. It's a chance to share ideas and learn something new. You can be just a Django hobbyist instead of a professional. All you have to be is passionate. At the event, we'll put up a board with slots for talks. Attendees can put themselves into these slots for talks. This makes for a fun, fluid event where new speakers are as welcome as experienced speakers. While this is meant to be an informal, beginner-friendly event, a professional level of conduct is still required: Speakers, like all attendees must agree to the code of conduct (also listed on the event page). No sales or recruiting … -
Announcing BarCamp Django SF!
BarCamp Django SF! On October 4th and 5th BarCamp Django SF will be taking place in the Eventbrite office in San Francisco. BarCamp Django SF is a low-cost, community-focused event that's different than any previous multi-day Django conference. So how is BarCamp Django SF different than previous Django conferences and events? Speakers are determined at the event I know what you are thinking. It's something on the line of "What the heck?!?" It means that if you want to give a talk, you don't need to be an expert. We don't have an formal, extensive review process. It's a chance to share ideas and learn something new. You can be just a Django hobbyist instead of a professional. All you have to be is passionate. At the event, we'll put up a board with slots for talks. Attendees can put themselves into these slots for talks. This makes for a fun, fluid event where new speakers are as welcome as experienced speakers. While this is meant to be an informal, beginner-friendly event, a professional level of conduct is still required: Speakers, like all attendees must agree to the code of conduct (also listed on the event page). No sales or … -
High Performance Django: Shipped
I'm excited to announce that our book, High Performance Django is officially complete. You can buy a copy at highperformancedjango.com now. Thank You Writing the book was hard work and there were definitely times where the challenge felt insurmountable. I couldn't have completed the book without the efforts of a lot of other people: Yann Malet The book's co-author. His real world experience and technical detail were pivotal to the work. Kickstarter Backers Knowing that almost 400 people were counting on having the book was what pushed me through the difficult times. Thank you for putting your faith in the project. Mark Wirblich Mark is behind the design of the book and site. He is new to Lincoln Loop and led the project beautifully. Valerie Coulman Valerie, the book's editor, provided sage advice and the output is far better because of her involvement. Jen Luft Jen managed the delivery of the backer rewards around the world. She is a master of scheduling and coordination. Joni Trythall Joni was in charge of epub and Kindle layouts. She quickly picked up a new set of tools and helped fix some major problems with the small formats. Lincoln Loop Everyone else at Lincoln … -
High Performance Django: Shipped
I'm excited to announce that our book, High Performance Django is officially complete. You can buy a copy at highperformancedjango.com now. Thank You Writing the book was hard work and there were definitely times where the challenge felt insurmountable. I couldn't have completed the book without the efforts of a lot of other people: Yann Malet The book's co-author. His real world experience and technical detail were pivotal to the work. Kickstarter Backers Knowing that almost 400 people were counting on having the book was what pushed me through the difficult times. Thank you for putting your faith in the project. Mark Wirblich Mark is behind the design of the book and site. He is new to Lincoln Loop and led the project beautifully. Valerie Coulman Valerie, the book's editor, provided sage advice and the output is far better because of her involvement. Jen Luft Jen managed the delivery of the backer rewards around the world. She is a master of scheduling and coordination. Joni Trythall Joni was in charge of epub and Kindle layouts. She quickly picked up a new set of tools and helped fix some major problems with the small formats. Lincoln Loop Everyone else at Lincoln … -
My Talk "Factory Boy Fun" at Django London Meetup
On Tuesday I gave another talk at the London Django Meetup Group, titled "Factory Boy Fun", based upon my previous blog post of the same name. The blog post covers pretty much the same stuff, but if you want to flick through the slides quickly for an overview, here they are: -
My Talk "Factory Boy Fun" at Django London Meetup
On Tuesday I gave another talk at the London Django Meetup Group, titled “Factory Boy Fun”, based upon my previous blog post of the same name. The blog post covers pretty much the same stuff, but if you want to flick through the slides quickly for an overview, here they are: -
My Talk "Factory Boy Fun" at Django London Meetup
On Tuesday I gave another talk at the London Django Meetup Group, titled "Factory Boy Fun", based upon my previous blog post of the same name. The blog post covers pretty much the same stuff, but if you want to flick through the slides quickly for an overview, here they are: -
How to add a group choice combo box in a Django user profile form
Assume that you have a Django project where each user belongs to just one group, say Registered or Admin, but not both. You want to show a form in your front-end to let Admin users edit the user profiles, where each user profile is made with First name, Last name, Email and the user group. This task can be accomplished very easily! What you need is a customized ModelForm to add the possibility to edit the user group together with the other fields, and a customized UpdateView to let you set the form initial data for the group field, and to save the changes correctly. Here is the ModelForm: from django import forms from django.contrib.auth.models import User, Group class UserProfileForm(forms.ModelForm): group = forms.ModelChoiceField(queryset=Group.objects.all(), required=True) class Meta: model = User fields = ['first_name', 'last_name', 'email', 'group'] That is a standard ModelForm for the User model, we have just added a group field that is a ModelChoiceField, that is a combo box with all available groups in our project as choices, if you want you can filter the queryset according to your needs. We have also restricted the fields shown in the user profile form to First name, Last name, Email and … -
Understanding get_absolute_url
URL's can be a pain at times, but with get_absolute_url on your model it can make dealing with them on a per-object basis much simpler and cleaner accross your entire site. Not to mention Django itself loves to use get_absolute_url, so it will make other tasks a lot easier.Watch Now... -
DjangoCon 2014: Recap
Caktus had a great time at DjangoCon in Portland this year! We met up with old friends and new. The following staff gave talks (we’ll update this post with videos as soon as they’re available): Mark Lavin, Technical Director, gave two talks: Anatomy of a Django Project and REST: It’s Not Just for Servers. In the photos, you’ll also notice Mark doing some signings of Lightweight Django, his O’Reilly book (already a bestseller on O’Reilly’s list). Karen Tracey, Lead Developer, Technical Manager, Django core committer, and Django Software Foundation member (whew!) answered the question “What is the Django Admin Good For?”. We helped design the website, so it was gratifying seeing the hard work of our design team displayed on the program ad and various points throughout the conference. For fellow attendees, you probably noticed our giant inflatable duck, who came out in support of Duckling, our conference outings app. He told us he had a good time too. Here’s some pictures of our team at DjangoCon: -
Software Design
For some reason I was looking for job titles again today. It's something that I seem to spend time on a few times a year whenever I need to describe, in a few words, what it is that I do. I've never been happy with my assigned titles at work. Developer, Programmer, Architect, Engineer; none of them really embody all that I do, much less what I love doing. I love creating efficient solutions to complex problems. I like to build on the work of others and reuse as much as possible. I'm constantly learning about as much as I can so that I always know what's available. I love organized, elegant code. And I'm never satisfied with a workaround if I haven't figured out the root cause of a problem. Every job I've had, I end up taking on and becoming responsible for so much more than I was hired. I just can't seem to help it. I gravitate to what I love doing—I seem to have a knack for it—even though I never had a title for it. Then I came across the Wikipedia entry for Software Design, and I felt like my search had finally come to … -
Software Design
For some reason I was looking for job titles again today. It's something that I seem to spend time on a few times a year whenever I need to describe, in a few words, what it is that I do. I've never been happy with my assigned titles at work. Developer, Programmer, Architect, Engineer; none of them really embody all that I do, much less what I love doing. I love creating efficient solutions to complex problems. I like to build on the work of others and reuse as much as possible. I'm constantly learning about as much as I can so that I always know what's available. I love organized, elegant code. And I'm never satisfied with a workaround if I haven't figured out the root cause of a problem. Every job I've had, I end up taking on and becoming responsible for so much more than I was hired. I just can't seem to help it. I gravitate to what I love doing—I seem to have a knack for it—even though I never had a title for it. Then I came across the Wikipedia entry for Software Design, and I felt like my search had finally come to … -
Django Projects and Mercurial Subrepositories
A while back, Steve Losh posted some excellent Django advice, in particular the part on working with third-party apps. I thought it sounded interesting but was concerned that it would be a hassle to maintain. Once I finally tried it, it was quite liberating. Never again will I have to work around some issue with a package. Now I just fix it and move on. It did take a bit of work, though, to figure out an approach that I was happy with. I usually use a pip requirements file to keep track of project dependencies and I wasn't quite sure how to make it all work together. One option is to use pip's editable flag like so: # requirements.txt -e hg+https://bitbucket.org/andrewgodwin/south@64fdcc52cd010e663b7a8b9ad592d4aa204807a2#egg=South-dev What I didn't like about that was having to constantly update my requirements.txt to change the revision. And, by default, pip installs editable packages into $VIRTUAL_ENV/src while I'd rather they be in a subdirectory of my project for easy access. My first attempt at dealing with those issues was to fork every single package I was using, add a tag or branch for the revision my project was using and change the requirements.txt file to look like so: … -
Three cheers for SourceTree
I'm not a big fan of GUIs for version control software. On Windows I've tried all the Tortoise incarnations, but they always just seem to slow me down. The built in Git GUI was decent but, at the end of the day, it was always easier to just use the command line. When I switched to using a Mac full time, I didn't spend much time looking. I installed MacHg and GitHub for Mac but never used them. I was, though, having trouble finding a good Mac file comparison tool. On Windows I'd always been relatively happy with Beyond Compare. It was fast and has a ton of features. So, I still haven't found a decent comparison tool for Mac, but I did stumble onto a great VCS GUI. SourceTree has been absolutely great to work with. I pretty much have it open full time as there's no need to switch between apps (it does Git, Mercurial, and SVN). It just happens to have built-in integration for GitHub, BitBucket, and Kiln (of which I use all three). And, as far as I can tell, it's free. If you're on a Mac, I highly recommend it. -
Django 1.7 正式版的新功能介绍
Django开发者及爱好者们期待已久的 1.7 正式版前两天终于发布了,据Django官网的介绍,这一版本相对 […] -
从 Apache 2.2 升级到 2.4 需要更新哪些 Virtual Host 设置?
如果你和我们一样从Ubuntu 12.04升级到Ubuntu14.04, 那么你会发现Apache版本从2.2变成了2.4; 或者你只是将Apache 2.2升级为2.4. 那么你可能会发现Apache无法正常工作了. 你可以使用本篇中所提到的设置时Apache重新工作. 本篇中所提到的Virtual Host设置文件的更新是必须要做的, 否则Apache就无法工作. 本篇博文并不是一个完整的升级指导, 如果需要查看完整的升级指导, 请访问Apache官方升级指导 1. 备份 在升级之前请备份数据文件, 因为升级有可能会使你丢失数据. 2. Virtual Host设置更新 从apache 2.2升级到Apache 2.4: 对于Ubuntu和Debian, 在etc/apache2/sites-available目录中的文件必须以.conf结尾才能被读取 Virtual host设置中的Directory必须有Require all granted才行 <Directory /path/to/public/website/> Require all granted </Directory> 所以, 对于Ubuntu和Debian用户, 你需要修改Virtual host中的2处设置才能使Apache 2.4重新运作, 而其他Linux的用户则只需要做第二项的修改. a. 增加.conf扩展名 (针对Ubuntu和Debian用户) 我们可以使用mv命令为Virtual host文件添加cong扩展名: mv /etc/apache2/sites-available/example.com /etc/apache2/sites-available/example.com.conf 然后使用阿ensite命令重新增加virtual host, 不要忘了添加.conf后缀: a2ensite example.com.conf 对所有virtual host文件重复以上两步, 最后重新载入: sudo service apache2 reload b. 增加权限 (针对所有用户) 打开网站的virtual host文件, 例如/etc/apache2/sites-available/example.com.conf, 在VirtualHost下的Directory中添加Require all granted. 如果存在Require all denied, 则改为Require all granted: <VirtualHost *:80> ... <Directory /path/to/public/website/> Require all granted </Directory> ... </VirtualHost> 保存并对其他virtual host文件执行以上步骤, 最后重新载入: Ubuntu/Debian: sudo service apache2 reload CentOS: /etc/init.d/httpd reload Fedora: systemctl reload httpd.service 此时检查网站是否能正常运行. 3. 其他注意事项 升级过程中默认的virtual host文件可能会从/var/www变为var/www/html, 不要忘了重新静止它. 升级后如果有不兼容的模块的话, 这些模块也会组织apache正常运行, 此时Apache官方升级指导是检查的起点. -
Factory Boy Fun
I've recently been working on improving the test suite at YPlan. The biggest change is moving towards dynamic fixtures for our Django models using “Factory Boy”. This library is essentially a tool that lets you define simple helper functions to generate random, sensible model instances quickly; by using them in tests you can avoid the static JSON fixture files that Django recommends you use in tests by default. Factories are also general purpose - they just generate data and use it to create a model - and so they can be re-used to fill your development database rather than dumping from production. The problem Here's a typical test case: class MyTests(TestCase): fixtures = ['basic.json'] def setUp(self): self.user = User.objects.create( username='adam', first_name='Adam', last_name='Johnson', email='adam@example.com' ) # do some testing ... We have test data in two places with different maintenance strategies - ouch. Firstly, the 'basic.json' file contains JSON objects with data to be passed to the model constructor; and secondly, the call to User.objects.create which contains data in a different format. Also, it's really hard to tell which bits of the data the test depends on, since the fixtures are shared between tests, and to call create on a model … -
Factory Boy Fun
I've recently been working on improving the test suite at YPlan. The biggest change is moving towards dynamic fixtures for our Django models using “Factory Boy”. This library is essentially a tool that lets you define simple helper functions to generate random, sensible model instances quickly; by using them in tests you can avoid the static JSON fixture files that Django recommends you use in tests by default. Factories are also general purpose - they just generate data and use it to create a model - and so they can be re-used to fill your development database rather than dumping from production. The problem Here's a typical test case: class MyTests(TestCase): fixtures = ['basic.json'] def setUp(self): self.user = User.objects.create( username='adam', first_name='Adam', last_name='Johnson', email='adam@example.com' ) # do some testing ... We have test data in two places with different maintenance strategies - ouch. Firstly, the 'basic.json' file contains JSON objects with data to be passed to the model constructor; and secondly, the call to User.objects.create which contains data in a different format. Also, it's really hard to tell which bits of the data the test depends on, since the fixtures are shared between tests, and to call create on a model … -
Factory Boy Fun
I’ve recently been working on improving the test suite at YPlan. The biggest change is moving towards dynamic fixtures for our Django models using “Factory Boy”. This library is essentially a tool that lets you define simple helper functions to generate random, sensible model instances quickly; by using them in tests you can avoid the static JSON fixture files that Django recommends you use in tests by default. Factories are also general purpose - they just generate data and use it to create a model - and so they can be re-used to fill your development database rather than dumping from production. The problem Here’s a typical test case: class MyTests(TestCase): fixtures = ['basic.json'] def setUp(self): self.user = User.objects.create( username='adam', first_name='Adam', last_name='Johnson', email='adam@example.com' ) # do some testing ... We have test data in two places with different maintenance strategies - ouch. Firstly, the ‘basic.json’ file contains JSON objects with data to be passed to the model constructor; and secondly, the call to User.objects.create which contains data in a different format. Also, it’s really hard to tell which bits of the data the test depends on, since the fixtures are shared between tests, and to call create on a model … -
Geo+Django: Geo Beyond the Django slides
Geo+Django: Geo Beyond the Django slides -
New Django Server Setup: Part 1
New Django Server Setup: Part 1