Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
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! -
django-registration updates
Since announcing its resurrection a couple weeks ago, I’ve been working on django-registration pretty much continuously. There are over 30 commits since that last post, and I think it’s finally getting close to release quality; what’s left at this point is, I think, mostly stylistic cleanups and editing and pushing some more documentation. There are a couple big highlights from the past few weeks’ work, and I’d like to take a moment to go over those ... Read full entry -
django-registration updates
Since announcing its resurrection a couple weeks ago, I’ve been working on django-registration pretty much continuously. There are over 30 commits since that last post, and I think it’s finally getting close to release quality; what’s left at this point is, I think, mostly stylistic cleanups and editing and pushing some more documentation. There are a couple big highlights from the past few weeks’ work, and I’d like to take a moment to go over those ... Read full entry -
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. Tuesday: Django Authors Panel (1:30 pm) Meet Caktus Technical Director and co-author of Lightweight Django Mark Lavin at this panel of people who write about Django. Learn about the experience of writing or recording video about Django from a collection of talented tech authors! Wednesday: Intro to Client-Side Testing (11:50 am) You've just built a REST API and client-side application to consume it. With all your focus on architecture, you missed a critical piece: how do you test it? In this intermediate-level talk, Mark Lavin will look at some of the tools available to test this style of application with both Javascript unit tests and integration tests written in Python. Wednesday: Lightweight Django Book Signing (2:50 pm) Come meet co-author of Lightweight Django Mark Lavin and have him sign your copy. You can also say hello to everyone at our Caktus Group table! Thursday: DjangoGirls Austin Workshop (9:00 am) We’re a proud DjangoGirls sponsor and organizer of DjangoGirls RDU. … -
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. We usually check code formatting locally before committing, but we also have safety checks in place in case someone forgets (as I more than anyone have been known to do!). This prevents code formatting standards from slowly eroding over time. We accomplish this by making our continuous integration (CI) server "fail" the build if unclean code is committed. For example, using Travis CI, simply adding the following line to the script: section of your .travis.yml will fail the build if flake8 detects any formatting issues (the command returns a non-zero exit code if errors are found): - flake8 . You can adjust flake8 defaults by adding a file named setup.cfg to the top level of your repository. For example, we usually relax the 80 character limit a little and … -
django-registration
I mentioned a couple weeks ago that lately I’ve been in the process of providing updated releases for all the various open-source projects I maintain, and specifically mentioned a desire to resurrect django-registration which, once upon a time, was the most popular thing I’d ever written. Over the past week I’ve been focusing more heavily on that, and now it’s time to start talking about a release. Ancient history I’ve always felt pretty strongly that Django’s killer ... Read full entry -
django-registration
I mentioned a couple weeks ago that lately I’ve been in the process of providing updated releases for all the various open-source projects I maintain, and specifically mentioned a desire to resurrect django-registration which, once upon a time, was the most popular thing I’d ever written. Over the past week I’ve been focusing more heavily on that, and now it’s time to start talking about a release. Ancient history I’ve always felt pretty strongly that Django’s killer ... Read full entry -
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. All of these tools have lots of options and ways to use them. I'm not trying to cover all the possibilities here. I'm just showing what we ended up doing. Our requirements We had some specific goals we wanted to achieve in this reconfiguration. There should be no outside requests sneaking in -- the only requests that should reach the backend servers are those that come through the load balancer. We'll achieve this by setting the backend servers' security group(s) to only allow incoming traffic on those ports from the load balancer's security group. The site should only handle requests that have the right Host header. We achieve this already by Nginx configuration (server_name) and won't have to change anything. Redirect any non-SSL requests to SSL. The load balancer can't do this for us (as far as I could see), so we just forward … -
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 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. We are looking for candidates who would love to collaborate with us in our offices in downtown Durham, NC to directly contribute to both open source projects created at Caktus as well as open source projects used by Caktus, such as Django. As previously mentioned, this will be a part-time position and will be taking the place of our normal fall internship program. If successful, we may expand this into a full-time position for future iterations. I think this will be a great opportunity for a developer to get experience …