Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Utrecht javascript meetup summaries
Normally I attend python/django meetups, but tonight I attended the Utrecht (=middle of the Netherlands) javascript meetup for the second time. I don't have notes of the first one (that was much too visual to make writing something down worthwile), but this time I have. WebRTC datachannel - Roland van Laar Roland van Laar talks about web applications for education and webrtc data channels. Webrtc is p2p (peer to peer) for browsers. You can use it for audio, video. Datachannel is a bit like p2p websockets. Why did he wanted to use it? Well, he writes educational software. In elementary schools in the Netherlands, that often means a teacher and a digiboard. He showed a demo with a website that showed a six-figure code that the teacher then had to type in on his accompagnying phone app. After thus connecting the webbrowser to the phone, he could then steer the webbrowser from the phone. Advancing sheets, and so. The advantage about webrtc and p2p: it is a direct connection between the phone and the browser, without being dependent on the ofttimes-flaky school's internet connection. How do you build up a connection? The one that starts creates an RTCPeerConnection and creates … -
Automate Django Deployments with fabfile
Fabric is a Python library and command-line tool with the ability to execute commands on a remote server. It is designed to use SSH to execute system administration and deployment tasks on one or more remote machines. Usage To automate administration tasks and deployments. Typical usage involves creating a python module containing one or more functions, then executing them via the fab command-line tool. Installation Fabric requires Python version 2.5 or 2.6. The easiest ways of installing Fabric is via, pip, easy_install: $ pip install fabric (OR) $ sudo easy_install fabric (OR) $ sudo apt-get install fabric Fabric Functions Now, we learn about some of the functions in Fabric. Fabric provides a set of commands in fabric.api module: $ local # To execute a local command. $ run # To execute a remote command on all specific hosts, user-level permissions. $ sudo # To execute a command on the remote server with sudo (i.e. superuser) privileges. $ put # To copy the local file to a remote destination. $ get # To download a file from the remote server. $ prompt # Prompt user with text and return the input (like raw_input). $ reboot # To reboot the remote system, … -
django-semanticui-form
I'm working on a (side)project in Django that uses the awesome Semantic UI CSS framework. This project has some Django forms that are rendered on the server and so I can't let Django render the form HTML or else the CSS framework can't do its magic. The project is called django-semanticui-form and it's a fork from django-bootstrap-form. It doesn't come with the Semantic UI CSS files at all. That's up to you. Semantic UI is available as a big fat bundle (i.e. one big .css file) but generally you just pick the components you want/need. To use it in your Django templates simply, create a django.forms.Form instance and render it like this: {% load semanticui %} <form> {{ myform | semanticui }} </form> The project is very quickly put together. The elements I intend to render seem to work but you might find that certain input elements don't work as nicely. However, if you want to help on the project, it's really easy to write tests and run tests. And Travis and automatic PyPI deployment is all set up so pull requests should be easy. -
django-semanticui-form
I'm working on a (side)project in Django that uses the awesome Semantic UI CSS framework. This project has some Django forms that are rendered on the server and so I can't let Django render the form HTML or else the CSS framework can't do its magic. The project is called django-semanticui-form and it's a fork from django-bootstrap-form. It doesn't come with the Semantic UI CSS files at all. That's up to you. Semantic UI is available as a big fat bundle (i.e. one big .css file) but generally you just pick the components you want/need. To use it in your Django templates simply, create a django.forms.Form instance and render it like this: {% load semanticui %} <form> {{ myform | semanticui }} </form> The project is very quickly put together. The elements I intend to render seem to work but you might find that certain input elements don't work as nicely. However, if you want to help on the project, it's really easy to write tests and run tests. And Travis and automatic PyPI deployment is all set up so pull requests should be easy. -
z3c.recipe.usercrontab ported to python 3
z3c.recipe.usercrontab is a simple buildout recipe to add content to your buildout user's crontab. Our django sites often have something like this in our buildout configs, just to give you an idea of what you can do with it: [supervisor-cronjob] # Start supervisor (which in turn starts django and celery) # when the server starts. recipe = z3c.recipe.usercrontab times = @reboot command = ${buildout:bin-directory}/supervisord [django-session-cleanup-cronjob] recipe = z3c.recipe.usercrontab times = 14 3 * * * command = ${buildout:bin-directory}/django clearsessions Easy peasy. Especially starting the site @reboot is handy. You could also add an entry in /etc/init.d/your_site, but this way most of the setup of the site is handled for you by a single bin/buildout call. The previous release was in 2010: it simply didn't need any changes, it just performed the job it did and did it well :-) Now I've made a few small changes, mostly in the test code. Another package ported to python 3! -
Caktus at DjangoCon 2015
Django is kind of our thing, so we’ve been looking forward to DjangoCon 2015 for months! Now that it is finally here, we thought we would give a little preview of what Cakti will be up to at this year’s conference. -
Automation for better behaviour
Now... that's a provocative title! In a sense, it is intended that way. Some behaviour is better than other behaviour. A value judgment! In the Netherlands, where I live, value judgments are suspect. If you have a comment on someone's behaviour, a common question is whether you're "better" than them. If you have a judgment, you apparently automatically think you've got a higher social status or a higher moral standing. And that's bad, apparently. Well, I despise such thinking :-) Absolute values I think there are absolutes you can refer to, that you can compare to. Lofty goals you can try to accomplish. Obvious truths (which can theoretically be wrong...) that are recognized by many. Nihilism is fine, btw. If you're a pure nihilist: I can respect that. It is an internally-logical viewpoint. Only you shouldn't complain if some other nihilist cuts you to pieces if that suits his purely-individual nihilistic purposes. So for practical purposes I'm going to assume there's some higher goal/law/purpose/whatever that we should attain. Take programming in python. PEP 8, python's official style guide is recognized by most of the python programmers as the style guide they should adhere to. At least, nobody in my company … -
GoDjango Podcast Episode 1 - Interview with Luke Crouch
Listen in as we talk to Luke Crouch about upgrading from Django 1.4 to 1.7, MDN and discuss a potential move from a dedicated data center to AWS. -
How to make one view do the work of two
Hey folks! Today's is an interesting topic: making one view do two functions. In fact, you can make it do more than two; you an make them do 8 at a time. Think of it as view overloading, if you're into that kind of thing.So let's dive into it.Take logging into your account for example. Initially what I used to do is split this process into three views: one for displaying the login page, one for verification of credentials, and a third for displaying the profile. With the new method I will outline in this post you can do that using only two views rather than three. We'll combine displaying the login page and credential verification into one view. The way well do that will use HTTP request methods. Let's see what those are (going to take a little help from TutorialsPoint for the exact definitions):GET: This method is used to extract data that is embedded in the URL. The data is identified by a '?'. For example, in the URL "http://some.url/?data1=value1&data2=value2" the data after the '?' can be translated as {'data1':'value1', 'data2':'value2'}HEAD: This one is the same as GET, but this one only transfers status line and header sectionPOST: … -
Lessons learned from buildout a django site with a reactjs front-end
My colleague Gijs Nijholt just posted his blog entry lessons learned from building a larger app with React.js, which is about the javascript/reactjs side of a django website we both (plus another colleague) recently worked on. Simplified a bit, the origin is a big pile of measurement data, imported from csv and xml files. Just a huge list of measurements, each with a pointer to a location, parameter, unit, named area, and so on. A relatively simple data model. The core purpose of the site is threefold: Import, store and export the data. Csv/xml, basically. Select a subset of the data. Show the subset in a table, on a map or visualized as graphs. The whole import, store, export is where Django shines. The model layer with its friendly and powerful ORM works fine for this kind of relational data. With a bit of work, the admin can be configured so that you can view and edit the data. Mostly "view" as the data is generally imported automatically. Which means you discover possible errors like "why isn't this data shown" and "why is it shown in the wrong location". With the right search configuration and filters, you can drill down … -
Chicago Djangonauts meetup Sep 3, 2015
Chicago Djangonauts meetup Sep 3, 2015 -
A wagon-load of post-summer updates
Summer vacations are over and work resumes in Evennia land! Here's a wagon-load of small updates on what's going on. Ainneve The Ainneve project, the creation of an official, open-source Evennia demo game, has gotten going. The lead devs of the project are keen to make this a collaborative effort and there is a lot of good discussion and code being written. After some slowdown at the end of summer it's bound to pick up again. Ainneve's a rare chance to see a full MUD getting developed from scratch out in the open. The current issue list includes tags for difficulty and allows also newbie Python coders to jump in. Not to mention you have a chance to get valuable feedback on your work by seasoned coders! So if you are at all interested in making a MUD, try out Python/Evennia or just get involved in a semi-big programming project, this is a great chance to do so.Imaginary RealitiesSince a few weeks, there is a new issue of Imaginary realities (vol 7, issue 3) is out. As usual I have an article in it. This venerable e-zine was revitalized to include articles on both MU* as well as roguelikes, Interactive … -
Easy maintainance: script that prints out repair steps
At my work we have quite a number of different sites/apps. Sometimes it is just a regular django website. Sometimes django + celery. Sometimes it also has extra django management commands, running from cronjobs. Sometimes Redis is used. Sometimes there are a couple of servers working together.... Anyway, life is interesting if you're the one that people go to when something is (inexplicably) broken :-) What are the moving parts? What do you need to check? Running top to see if there's a stuck process running at 100% CPU. Or if something eats up all the memory. df -h to check for a disk that's full. Or looking at performance graphs in Zabbix. Checking our "sentry" instance for error messages. And so on. You can solve the common problems that way. Restart a stuck server, clean up some files. But what about a website that depends on background jobs, run periodically from celery? If there are 10 similar processes stuck? Can you kill them all? Will they restart? I had just such a problem a while ago. So I sat down with the developer. Three things came out of it. I was told I could just kill the smaller processes. … -
Testing SaltStack with Vagrant
Testing SaltStack with Vagrant -
Runs on python 3: checkoutmanager
Checkoutmanager is a five-year old tool that I still use daily. The idea? A simple ~/.checkoutmanager.cfg ini file that lists your checkouts/clones. Like this (only much longer): [local] vcs = git basedir = ~/local/ checkouts = git@github.com:nens/syseggrecipe.git git@github.com:buildout/buildout.git git@github.com:reinout/reinout-media.git git@github.com:rvanlaar/djangorecipe.git [svn] vcs = svn basedir = ~/svn/ checkouts = svn+ssh://reinout@svn.zope.org/repos/main/z3c.recipe.usercrontab/trunk In the morning, I'll normally do a checkoutmanager up and it'll go through the list and do svn up, git pull, hg pull -u, depending on the version control system. Much better than going though a number of them by hand! Regularly, I'll do checkoutmanager st to see if I've got something I still need to commit. If you just work on one project, no problem. But if you need to do quick fixes on several projects and perhaps also store your laptop's configuration in git... it is easy to forget something: $ checkoutmanager st /Users/reinout/vm/veertien/efcis-site M README.rst And did you ever commit something but forgot to push it to the server? checkoutmanager out tells you if you did :-) Porting to python 3. The repo was originally on bitbucket, but nowadays I keep having to look all over my screen, looking for buttons, to get anything done there. I'm … -
Getting Started with Django Admin
The admin is a very useful tool for developers to use when working with django. It is super easy to setup, and get your models registered with it so you can start CRUDing data.Watch Now... -
Making Clean Code a Part of Your Build Process (And More!)
At Caktus, “clean” (in addition to “working”!) code is an important part of our delivery. For all new projects, we achieve that by using flake8. flake8 is a wrapper around several tools: pep8, pyflakes, and McCabe. pep8 checks to make sure your code matches the PEP 0008 style guidelines, pyflakes looks for a few additional things like unused imports or variables, and McCabe raises warnings about overly complex sections of code. -
Amazon SES - Handling Bounces and Complaints.
Why do we go for Bounce and Complaint Handling while sending mails? In general while sending emails, we will prepare some recipient addresses as our mailing list, which are valid and our recipients want and expect our mail. But some times, some emails which are invalid will bounce, and if valid recipients do not want your mail, they may mark your email as spam in their email client. High bounce and complaint rates put your account at risk of being shut down. So in order to avoid such problem we'll handle the bounces and complaints and will remove those emails for not sending any mails further. Flow of Bounce and Complaint handling in AWS using SNS: In order to handle bounces and notifications AWS provides a service called SNS(Simple Notification Service). Using this feature we can handle bounces or complaints by configuring an webhook end point or email or using amazon's SQS service. As Django developers we'll try to know of how to handle bouce or complaints using webhooks in the current blog post. For this we'll use amazon's boto package as development API. 1. First we need to create an SNS Topic. An SNS Topic is a communication channel to … -
Amazon SES - Handling Bounces and Complaints.
Why do we go for Bounce and Complaint Handling while sending mails? In general while sending emails, we will prepare some recipient addresses as our mailing list, which are valid and our recipients want and expect our mail. But some times, some emails which are invalid will bounce, and if valid recipients do not want your mail, they may mark your email as spam in their email client. High bounce and complaint rates put your account at risk of being shut down. So in order to avoid such problem we'll handle the bounces and complaints and will remove those emails for not sending any mails further. Flow of Bounce and Complaint handling in AWS using SNS: In order to handle bounces and notifications AWS provides a service called SNS(Simple Notification Service). Using this feature we can handle bounces or complaints by configuring an webhook end point or email or using amazon's SQS service. As Django developers we'll try to know of how to handle bouce or complaints using webhooks in the current blog post. For this we'll use amazon's boto package as development API. 1. First we need to create an SNS Topic. An SNS Topic is a communication channel to … -
Improving page speed score in Google Page Score test- PART2
In our previous blog post we got an idea of what are the things that Google's Page Speed Insights will take into count to give page socre, now in the present blog post we'll get to know what are the techniques we can use to improve the page scrore. 1. Reducing the Server response time: As a programmer one of the reasons of the high server response time is due to redundancy in the queries. The following the cases where we use redundancy of queries and how can we reduce them. We use .exists() method, while querying to check if the DB object exists or not. Suppose we are having a model called 'Assessment'. The following is a code snippet with wrong usage of .exists(). if Assessment.objects.filter(id=assess.assessment_id, edu_class_id=role.edu_class_id, subject_id=role.subject_id).exists(): assessments_list = assessments_list + list(Assessment.objects.filter(id=assess.assessment_id,edu_class_id=role.edu_class_id,subject_id=role.subject_id)) In the above code the query 'Assessment.objects.filter(id=assess.assessment_id, edu_class_id=role.edu_class_id, subject_id=role.subject_id)' is repeated twice. Using the same query second time is of no use. The method .exists(), is to be used in such caases where the queryset result is not used anywhere else. We can rewrite the above code as below. assessments = Assessment.objects.filter(id=assess.assessment_id, edu_class_id=role.edu_class_id, subject_id=role.subject_id) if assessments: assessments_list = assessments_list + list(assessments) Similarly … -
Improving page speed score in Google Page Score test- PART2
In our previous blog post, we got an idea of what are the things that Google's Page Speed Insights will take into the count to give page score, now in the present blog post we'll get to know what are the techniques we can use to improve the page score. 1. Reducing the Server response time: As a programmer, one of the reasons of the high server response time is due to redundancy in the queries. The following the cases where we use redundancy of queries and how can we reduce them. We use .exists() method, while querying to check if the DB object exists or not. Suppose we are having a model called 'Assessment'. The following is a code snippet with the wrong usage of .exists(). if Assessment.objects.filter(id=assess.assessment_id, edu_class_id=role.edu_class_id, subject_id=role.subject_id).exists(): assessments_list = assessments_list + list(Assessment.objects.filter(id=assess.assessment_id,edu_class_id=role.edu_class_id,subject_id=role.subject_id)) In the above code the query 'Assessment.objects.filter(id=assess.assessment_id, edu_class_id=role.edu_class_id, subject_id=role.subject_id)' is repeated twice. Using the same query second time is of no use. The method .exists(), is to be used in such cases where the query set result is not used anywhere else. We can rewrite the above code as below. assessments = Assessment.objects.filter(id=assess.assessment_id, edu_class_id=role.edu_class_id, subject_id=role.subject_id) if assessments: assessments_list = assessments_list + … -
AWS load balancers with Django
We recently had occasion to reconfigure some of our existing servers to use Amazon Web Services Elastic Load Balancers in front of them. Setting this up isn’t hard, exactly, but there are a lot of moving parts that have to mesh correctly before things start to work, so I thought I’d write down what we did. -
Check out PyCon PL 2015 agenda
The PyCon PL 2015 will be held in Hotel Ossa Congress & Spa located in Ossa on October 15th through October 18th. The conference is held in Poland but consists of two blocks of talks - English and Polish, so non-Polish speaking attendees can benefit from it too. The agenda and other details can be found on the conference website. -
Working with Environment Variables in Python
If you look at modern code deployment practices, like in the 12 factor app, environment variables are very important for keeping secret information secret, or server specific information set for that server. All while not having long crazy settings in a settings file for every single server and computer. It helps keep things slimmer in your code along with the following quoted from the 12factorapp site: * Resource handles to the database, Memcached, and other backing services * Credentials to external services such as Amazon S3 or Twitter * Per-deploy values such as the canonical hostname for the deploy What Are Environment Variables? Environment variables are a key value pairs that can affect how a program runs. They need to be set at some point before a process is run so the process can read them in and act accordingly. A lot of times in production environments your database name and password are set as environment variables so that information does not end up in a code repository somewhere. By relying on an environment variable your code doesn't care what a setting is because you can set that at some other point. Actually working with environment variables is really simple. … -
Announcing the Caktus Open Source Fellowship
We are excited to announce the creation and funding of a pilot program for open source contributions here at Caktus Group. This program is inspired by the Django Software Foundation’s fellowship as well as the Two Day Manifesto. For this program, Caktus seeks to hire a part-time developer for twelve weeks this fall for the sole purpose of contributing back to open source projects. Caktus builds web applications based on open source tools and the continued growth of these projects is important to us. Open source projects such as Python and Django have given so much to this company and this is one of many ways we are trying to give back.