Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Levee (dike) experiments website
In the Netherlands, we're holding levee (dike) experiments at the IJkdijk location. Two levees have been build, stuffed full with various sensors. The goal? To get those levees to break and to validate which sensors provide useful monitoring data. There are two types of failure which they're testing: Piping. A sand layer is placed under the levee where water can seep through, undermining the levee. Macro stability. Tanks of water are placed on top of the levee, pushing water into the inner part of the levee. After a while, the pressure is too big and the levee will burst/collapse/fail. All those monitors are connected to a central database. We (Nelen & Schuurmans) participated together with Fugro. Fugro loaded the data into their Geodin database, we showed the data in a website using our Lizard (build with Django) framework. What we used a lot: the Flot javascript graph library for beautiful graphs. The website is only accessible on the experiment location itself, so I made myself a short movie so you can get an idea anyway: -
Announcing djangonauts.org
This morning during the DjangoCon US Lightning Talks, I announced the launch of djangonauts.org, a directory of Django user groups worldwide. Any and all Django user groups are welcome to visit the site and list their site for free. In addition, if your user group does not have an ... -
The missing library: ad-hoc queries for your models
I think it would be great if more sites allowed users (or consumers of their APIs) to produce and execute ad-hoc queries against their data. In this post I'll talk a little bit about some ways sites are currently doing this, some of the challenges involved, my experience trying to build something "reusable", and finally invite you to share your thoughts. A few popular ways of doing ad-hoc queries The Advanced search form One easy way to express an ad-hoc query is with an "advanced search" form, which provides full-text search and numerous options to narrow the results -- as a web-monkey who has coded up quite a few of these, I can say that in the simple case they are quite easy to write and usually consist of a series of if statements that build up the WHERE clause of a query. When the result set is very large it can also be useful to pair advanced search with drill-down. Building good drill-down search can be hard work as you need to compute "summary" information for various facets of your result set. Advanced search combined with drill-down is something I see on all the big e-commerce sites. It seems … -
DjangoCon 2012 Slides For "API Design Tips"
DjangoCon 2012 Slides For "API Design Tips" -
Thoughts on my stack
I'm an open source developer. I use Python, Django, PostgreSQL, JQuery, MongoDB, Memcached, and Redis. I push production code to Linux servers. And yet: My laptop runs Apple's Mac OS X. My primary editor is Sublime Text. My production servers are provided mostly by Heroku. All my sites are hosted on Amazon EC2. I've got nothing against Apple, Heroku, or Amazon, but their tools are not open source. And that's food for thought. -
Thoughts on my stack
I'm an open source developer. I use Python, Django, PostgreSQL, JQuery, MongoDB, Memcached, and Redis. I push production code to Linux servers. And yet: My laptop runs Apple's Mac OS X. My primary editor is Sublime Text. My production servers are provided mostly by Heroku. All my sites are hosted on Amazon EC2. I've got nothing against Apple, Heroku, or Amazon, but their tools are not open source. And that's food for thought. -
Lỗi khi chạy manage.py createsuperuser
Hôm nay quay lại làm một ứng dụng nhỏ trên Django với môi trường MacOS (Mountain Lion). Mọi thứ có vẻ rất ổn cho đến khi gặp lỗi với dòng lệnh để tạo một superuserpython manager.py createsuperuser Lỗi được hiển thị ra như sau:Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/HuyVu/study/workenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line utility.execute() File "/HuyVu/study/workenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/HuyVu/study/workenv/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv self.execute(*args, **options.__dict__) File "/HuyVu/study/workenv/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute output = self.handle(*args, **options) File "/HuyVu/study/workenv/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 70, in handle default_username = get_default_username() File "/HuyVu/study/workenv/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 105, in get_default_username default_username = get_system_username() File "/HuyVu/study/workenv/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 85, in get_system_username return getpass.getuser().decode(locale.getdefaultlocale()[1]) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 496, in getdefaultlocale File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 428, in _parse_localename ValueError: unknown locale: UTF-8Hoá ra django không lấy được Locale mặc định của hệ thống. Để khắc phục lỗi này, chúng ta khai báo thêm biến LANG và LC_ALL vào môi trường bằng cách cho thêm 2 dòng sau vào ~/.bash_profileexport LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8Sau đó nhớ kích hoạt sự thay đổi nàysource ~/.bash_profileVà bây giờ có thể thực hiện tạo superuser một cách bình thường.Blog's topic: Lập trìnhBlog's tag: Django -
Django Project Plugin 3.1.3 for Gedit
New fixes to my Django Project Plugin allow for virtualenv and Django 1.4.x -
Better Customer Support with eventlog
In web apps where users are doing various activities in your site, things can get complicated in a hurry that can make troubleshooting both customer support issues as well as exceptions very tricky. Tracking the flow of user activity is critical to understanding what happened and is not always easy to decipher at granular levels through analytics services such as Google Analytics. As a compliment to these services, Eldarion wrote eventlog. It’s a simple pluggable app that you add to your site and then log events throughout your code. The usage of eventlog is pretty simple: from eventlog.models import log log( user=user, action="SOME_ACTION", extra={ "key": "value" } ) Oftentimes, I hook up a bunch of signal receivers from external apps just for logging various activity on the site. In this above contrived example, user is optional, but if you supply it, it should be an authenticated user. The action is what is used in the Django admin for filtering, so give some consideration in naming. I typically prefix similar actions, or actions from the same app, with the same prefix so they are visually grouped together in the filter list. This is especially important as the number of different actions increase. … -
Thoughts on my stack
I'm an open source developer. I use Python, Django, PosgreSQL, JQuery, MongoDB, Memcached, and Redis. I push production code to Linux servers. And yet: My laptop runs Apple's Mac OS X. My primary editor is Sublime Text. My production servers are provided mostly by Heroku. All my sites are hosted on Amazon EC2. I've got nothing against Apple, Heroku, or Amazon, but their tools are not open source. And that's food for thought. -
Caktus Team Members Presenting at DjangoCon 2012
Caktus is proud to announce that four of our developers will be presenting at this year’s DjangoCon. We are also happy to announce that we will be sponsors of DjangoCon, taking place in Washington D.C. on September 4th through the 7th. In addition to the four Caktus team members who will be presenting this year, our entire development staff will be in attendance enjoying the conference and city. Karen Tracey and myself will be presenting a talk OpenBlock: Overview and Initial Experience about the implementation of OpenBlock for the OpenRural project. OpenBlock, released to the community from the Knight-funded project, EveryBlock, is a neighborhood news project aiming to provide a framework for hyper-local civic data. Over the past few years, the open source project has been maintained by the non-profit OpenPlans. OpenBlock is not available in every city so we worked with Ryan Thornburg of the UNC School of Journalism and Mass communications to bring OpenBlock to rural North Carolina newspapers by implementing OpenRural. This talk will focus on Colin and Karen’s experience with OpenBlock as they work to deploy OpenRural in North Carolina Mark Lavin will be giving a talk entitled Maintaining Your Sanity While Maintaining Your Open Source … -
Aiding tests with Ludibrio stubs and mocks
In tests we assume some input data and check if the output is equal to what we expect it to be. Sometimes is impossible to set the initial data as the code fetches some data from a third party API, or creates some data on its own (like random data). To aid testing of such code we can use ludibrio. It can mock or stub existing classes or functions making them work as we program it. -
Заметки с DjangoCon 2011
Выдалось немножко свобдного времени, решил набросать быстрых заметок про DjangoCon 2011 в Потленде. Признание Я не хотел ехать на конференцию сначала. Потому что последние полгода-год всё связанное с Джанго, Питоном, интернетом, да и вообще компьютерами стало навевать на меня тоску. Да и конференции со временем утратили очарование новизны: приехал, послушал доклады, которые лучше было бы прочитать текстом, уехал — только время потерял. Однако потом передумал, потому что… да просто потому что Портленд от меня теперь в трёх-четырёх часах езды. Как теперь потихоньку понимаю, передумал не зря. Похоже, эта конференция пропитана каким-то особым духом Хабанбай-Батыра, и я снова начинаю получать удовольствие от происходящего :-). Я наконец понял, что надо не доклады слушать, а с людьми разговаривать :-). Организация Главный организатор конференции — Стивен Холден, председатель PSF, который на этом деле собаку съел (PyCon тоже он организует). Результат — организация на уровне Just Works® с отсутствием каких бы то ни было заметных проблем: DjangoCon оплачивает всем участникам отельный WiFi, так как сами отели пока ещё не додумались, что это людям несколько важнее трёх комплектов полотенец в одноместном номере. В конференц-залах работает отдельный WiFi, без которого отельная сеть бы загнулась. Он всё же иногда мигает, но довольно редко. В конференцию входит завтрак, обед … -
Function Based Views Are My First Love
There is something special about your first love. It is possible be too attached and not embrace the new hotness of say Class Based View (CBV). But after having a fling and then dating CBV for a while, I now know that Function Based Views will always have a special place in my heart, and I hope in Django. Let's look at a FBV: def foo(request, arg, template="foo.html"): # Do something return render(request, template, dict(bar="bar")) Simple. Beautiful. Easy to follow. An explicit context filled with exactly what is available in the template and what names those values have. No extra docs needed. Explicit request and response, and the path to get from one to the other is outlined in one place, in one file. This straight forward approach of FBVs also makes it easier to learn and debug. Most University Computer Science programs are moving away from teaching Object Oriented Programming first and instead focusing on functional and procedural programming because it is easier to learn. There is a time and a place to use the power of classes and in Django CBVs. Consider carefully if your problem is really the kind where you need to use the CBV shaped … -
Function Based Views Are My First Love
There is something special about your first love. It is possible be too attached and not embrace the new hotness of say Class Based View (CBV). But after having a fling and then dating CBV for a while, I now know that Function Based Views will always have a special place in my heart, and I hope in Django. Let's look at a FBV: def foo(request, arg, template="foo.html"): # Do something return render(request, template, dict(bar="bar")) Simple. Beautiful. Easy to follow. An explicit context filled with exactly what is available in the template and what names those values have. No extra docs needed. Explicit request and response, and the path to get from one to the other is outlined in one place, in one file. This straight forward approach of FBVs also makes it easier to learn and debug. Most University Computer Science programs are moving away from teaching Object Oriented Programming first and instead focusing on functional and procedural programming because it is easier to learn. There is a time and a place to use the power of classes and in Django CBVs. Consider carefully if your problem is really the kind where you need to use the CBV shaped … -
Combining Twisted and Django
Franco Nero as the twisted gunslinger DjangoNewcomers to Evennia sometimes misunderstand it as being a "Django mud codebase somehow using Twisted". The correct description is rather that Evennia is a "Twisted-based mud server using Django". Allow me to elaborate.A mud/mux/moo/mu* is per definition a multi-user online game system. All these users need to co-exist on the server. If one player does something, other players shouldn't have to (noticeably) wait for that something to end before they can do anything. Furthermore it's important for the database schema to be easy to handle and upgrade. Finally, in a modern game, internet presence and web browser access is becoming a must. We combine two frameworks to achieve this.Two frameworks combinedTwisted is a asynchronous Python framework. "Asynchronous" in this context means, very simplified, that Twisted chops up code execution into as small bits as the code lets it. It then flips through these snippets rapidly, executing each in turn. The result is the illusion of everything happening at the same time. The asynchronous operation is the basis for the framework, but it also helps that twisted makes it easy to support (and create) a massive range of different network protocols.Django implements a very nice abstract Python … -
Moving Sentry from Heroku to Hardware
Update: Don’t decide against Heroku just because you’ve read my blog. It makes some things (especially prototyping) very easy, and with certain kinds of applications it can work very well. I’ve talked a lot about how I run getsentry.com, mostly with my experiences on Heroku and … -
Moving Sentry from Heroku to Hardware
Update: Don't decide against Heroku just because you've read my blog. It makes some things (especially prototyping) very easy, and with certain kinds of applications it can work very well. I've talked a lot about how I run getsentry.com, mostly with my experiences on Heroku and how I switched ... -
Pensar en el manteniment compensa
Avui, fa poques hores hem posat en producció una nova web per Fiesta Hotel Group anomenada Palladium Weddings és una web pensada per pantalles grans, on s'intenta mostrar el que és el producte de noces que té el client. Si us pensau casar aviat o renovar vots, no deixeu de fer-li una ullada, els escenaris i ambients són una autèntica meravella. Com és habitual la web està desenvolupada amb Django i pensada per a suportar una càrrega important de visites, i a la vegada fer que el manteniment dels continguts sia el més ràpid possible. Pensau que muntar un paquet de noces, amb tot els extres, fotografies, escenaris, ... no és una tasca trivial. Ens hem de posar amb la pell no tan sols del client potencial que visita la web, sinó de la gent que l'ha de mantenir, i per tant l'aplicació s'ha de cuidar tant en l'aspecte visible com en el que es veu menys, però que també té una part fonamental en l'èxit de la web. Si aconseguim fer una web fàcil de mantenir és més senzill que els continguts es mantenguin actualitzats i que la web estigui més viva. Però a part d'aquestes consideracions, per mi … -
Django scaffolding
We all love Django — a simple but powerful framework. However, Ruby on Rails has at least one (and few others I’m sure!) advantage: scaffolding. It allows developers to create the models, views, and templates in a single operation. It’s an interesting solution — you don’t have to manually create all the things that usually take a lot of time. So why don’t we have this feature in Django? Well… now we do! Our latest django-common 0.3 comes with a scaffolding feature! Overview Here is what django-common scaffold can do: - create app, - create models, - create views, - create templates, - create forms, - create urls, - create tests. Scaffold creates the app (similar to startapp that ships with Django), models with fields, CRUD views with ajax forms, prepares templates, fills urls, and creates CRUD tests with only one command! Installing Use pip installer: pip install django-common-helpers Or just download/clone directly from github: https://github.com/Tivix/django-common Then add it (django_common) to INSTALLED_APPS and set up SCAFFOLD_APPS_DIR in settings. Default is set to main app directory. However if you use django_base_project you must set up this to SCAFFOLD_APPS_DIR = ‘apps/’. Run scaffold, run! To run scaffold type:python manage.py scaffold APPNAME --model … -
Moving Sentry from Heroku to Hardware
Update: Don't decide against Heroku just because you've read my blog. It makes some things (especially prototyping) very easy, and with certain kinds of applications it can work very well. I've talked a lot about how I run getsentry.com, mostly with my experiences on Heroku and how I switched ... -
Integrating reCAPTCHA
Recently we've been looking into using reCAPTCHA for a form on the 2degrees site. We took a look at the python libraries out there and found that they either didn't meet our requirements or weren't sufficiently documented to allow a quick integration with our software.So, we've developed a couple of open-source libraries to allow easy communication with the reCAPTCHA service:python-recptcha is an alternative to the client that google suggest. We've created a fully-tested and well-documented alternative which allows access to the whole API. The main advantage here, is the ability to access the different themes on offer.django-recaptcha-field is a small library which contains a factory for generating a Django form with a reCAPTCHA field in. All the other libraries we found worked around passing the client IP address to the reCAPTCHA service. Given that the API documentation states that this is a mandatory field, we've ensured that this is sent.If you have any suggestions for future improvement in these libraries, we'd love to hear from you. Of course, if you'd like to make the changes yourself you can always fork the libraries on github! -
Integrating reCAPTCHA
Recently we've been looking into using reCAPTCHA for a form on the 2degrees site. We took a look at the python libraries out there and found that they either didn't meet our requirements or weren't sufficiently documented to allow a quick integration with our software. So, we've developed a couple of open-source libraries to allow easy communication with the reCAPTCHA service: python-recaptcha is an alternative to the client that google suggest. We've created a fully-tested and well-documented alternative which allows access to the whole API. The main advantage here, is the ability to access the different themes on offer. django-recaptcha-field is a small library which contains a factory for generating a Django form with a reCAPTCHA field in. All the other libraries we found worked around passing the client IP address to the reCAPTCHA service. Given that the API documentation states that this is a mandatory field, we've ensured that this is sent. If you have any suggestions for future improvement in these libraries, we'd love to hear from you. Of course, if you'd like to make the changes yourself you can always fork the libraries on github! -
Accessibility: Look at What's Out!
Overnight, my book on making accessible websites was released. It's my first book, and I'm completely over the moon. Not only do I get my own animal, but I get to put a book out on something I'm passionate about. I get to help break the paradigm that accessibility is too expensive, just about the blind, or only benefits a small portion of the population. Even better is the timing: I'm teaching a tutorial at DjangoCon on making accessible websites. I've been super jazzed about being able to do more than drive-by conversations with people about accessibility. It's one of those topics that many people approach with skeptisism, but leave with a budding interest. This time, I'll be able to take that interest and mold it into a deeper understanding in what it means to be accessible. We also get to improve a really bad restaurant site, which I think will be cathartic for most of us. There's space at the tutorial, so if you're at DjangoCon or in the DC area, you can still sign up! And heck, you can say you took a class on accessibility from the woman who wrote a book on it. -
Pushing a git branch
We're using git for most django projects now. There's one big problem I had: if I make a branch and want to push my changes to github, I sometimes get an error complaining that I'm behind on other branches so that my changes can't be pushed. The "solution" is to do a git checkout master, pull there (which updates my master pointer), and checkout back to my branch. Now I can push. This is pretty irritating. Why can't I just push the branch I'm working on? I found the solution on stackoverflow: git config --global push.default current This pushes only the current branch by default. Just what I wanted.