Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Mercurial Mirror For Django 1.10 branch
Following the recent 1.10-beta1 release, here is our usual “production” mirror, aimed at: being a lightweight read-only repository to clone from for production servers hide the ugly git stuff behind a great mercurial interface The clone is at the usual location at bitbucket, from which you can browse, clone, update, … https://bitbucket.org/orzel/django-1.10-production/ -
Python for OPS and platform teams - Pavel Chunyayev
(One of the talks at the 22 June 2016 Amsterdam Python meetup) The sub-title of his talk is supporting development teams in their journey to Continuous Delivery. Pavel's job description is continuous delivery architect. He loves biking so he just had to move to Amsterdam :-) What is continuous delivery? Often you'll hear something like "safely, rapidly and predictably deliver new features to production". But that's a little bit restricted. He likes to start already in the inception and planning stage and only end in the actual operation stage. So the whole process. You don't want to continuously deliver bad features that won't be used. You want to include the inception/planning stage to make sure the right features are implemented. A core idea is to keep the product releasable: build quality in. That is the core that we ought to remember. Quality is an integral part of the product, it is not something you can tack on later. So... quality in the entire build/test/release cycle. Build. All the checks you can do. Linting, static code analysis, unit tests. Test. Contract tests, end-to-end testsuites, browser tests, scaling tests. Release. Verify the deploy. Especially in the "test" phase, you need specific clean … -
A high availability Django setup on the cheap - Roland van Laar
(One of the talks at the 22 June 2016 Amsterdam Python meetup) Roland build an educational website that needed to be high available on a tight budget. He demoed the website. A site for the teacher on his own laptop and a separate page for on the digiboard for the class. The teacher steers the digiboard from his laptop (or an ipad or phone). As it is used in classrooms, it needs to be really really available. As a teacher, you don't want to have to change your lesson plan at 8:30. The customer hat three goals: Not expensive. Always up. Reliable. He had some technical goals of his own: Buildable. Functional. Maintainable. Always up? Django? You have the following challenges, apart from having a bunch of webservers. Media files. Files uploaded on one server need to be visible on others. Websockets. Database. Sessions. The setup he chose: Front end (html, javascript, images): cloudflare as CDN, content delivery network. The front end is a single page jquery app. It chooses a random API host for ajax requests. It changes API hosts when the API is not responding. But.... when is an API not responding? Some schools have really bad internet, … -
What are distributed systems? - Quazi Nafiul Islam
(One of the talks at the 22 June 2016 Amsterdam Python meetup) Distributed systems? Distributed computation (like hadoop, mapreduce). Distributed storage (like cassandra, riak). Distributed messaging (like kafka). You need distributed systems if you want to do more than is regulary possible. With many systems you need things like synchronisation (for instance NTP, network time protocol). A distributed system is a bunch of computers working together. Such systems have challenges and limitations. Take for instance the CAP theorem for distributed storage systems. You can't have all three of the following three at the same time: Consistency. Availability. Partition tolerance. You can for instance value availability over consistency. You give the answer as soon as possible, even if you're not completely sure you have the full answer (as other nodes might have extra/newer information). -
Query Expressions are Amazing
The Django 1.8 release added support for complex query expressions. The documentation has some nice examples but they don't do justice to how crazy awesome these are. In this post, we will go through some additional examples of how to leverage these expressions. -
The Journal of Medical Internet Research Features Epic Allies Phase 1 Study Results
The Journal of Medical Internet Research recently published “Epic Allies: Development of a Gaming App to Improve Antiretroviral Therapy Adherence Among Young HIV-Positive Men Who Have Sex With Men”. Epic Allies, initially funded by a federal Small Business Innovation Research (SBIR) grant, represents a partnership between Caktus, UNC’s Institute of Global Health and Infection Diseases, and Duke Global Health Institute. -
The Philosophy of Channels
Why is Channels designed like it is, and what does it really mean for Django, Python, and WebSocket handling? It's been a while since my last blog post about Channels, and a lot has happened in the meantime - the API has developed out and stabilised, features like backpressure have come along, and the situation for backends is looking a lot better, especially once the local-and-remote combination layer matures some more. The other thing that has happened, however, is confusion and worry over the direction Channels is headed, and the direction it spells for Django and Python overall. A lot of the development of Channels was addressing and tackling my own personal worries with its direction, and picking the right set of tradeoffs, sometimes from two equally valid options. I've not been as proactive as I could have been at communicating my reasoning and long-term vision for what Channels could do; I'm hoping this blog post will rectify some of that. Let me take you through the specific set of problems I'm looking to tackle, why I chose to design things the way I did, and what I see as the path forwards. It's not just about WebSockets A lot … -
PyCon 2016 Recap
PyCon, beyond being the best community event for Python developers, is also an event that we happily began thinking about eleven months ago. Almost as soon as PyCon 2015 ended, we had the good fortune of planning the look and feel of PyCon 2016 with organizer extraordinaires Ewa Jodlowska, Diana Clark, and new this year, Brandon Rhodes. Our team has loved working with the organizers on the PyCon websites for the past three years now. They’re great people who always prioritize the needs of PyCon attendees, whether that’s babysitting services or a smooth PyCon web experience. -
My First Conference Talk: Reflecting on Support and Inclusivity at DjangoCon Europe 2016
The environment at Caktus is, above all, one of encouragement. I experienced that encouragement as an intern and continue to experience it as a full-time developer. In addition to providing workplace mentorship, Caktus encourages all of its employees to submit talks to conferences. My manager Mark Lavin and mentor Karen Tracy encouraged me to get over my concerns about being new to the field and to start submitting talks. -
Ports and Adapters in python - part three
Next part of my application will be module for saving links to read them later. In the last post, I made a reddit search view for the specific keyword that display results to the user. To save them to read later I need database representation of link from reddit: from django.db import models class RedditLink(models.Model): title = models.CharField(max_length=250) is_favourite = models.BooleanField(default=False) def save(self, *args, **kwargs): if self.is_favourite: super(RedditLink, self).save(*args, **kwargs) I made my own save because I only need links that are favorite in my database. In addition, I have multiple reddit links on my search page to save. So how to handle multiple forms of the same model in django? The answer is to use Fromset. What is it? It is module provided by django for creation multiple forms. How to use it? Look at forms.py: from django import forms from .models import RedditLink RedditAddToFavouritesFormset = forms.modelformset_factory( RedditLink, fields=('title', 'is_favourite'), extra=5 ) I used something called forms.modelformset_factory which is a function to produce fromset from model. So I provided model name with fields to calling this function. What is more, I add additional argument extra for creating more than one form in formset. How to use newly created RedditAddToFavouritesFormset? … -
Ports and Adapters in python - part three
Next part of my application will be module for saving links to read them later. In the last post, I made a reddit search view for the specific keyword that display results to the user. To save them to read later I need database representation of link from reddit: from django.db import models class RedditLink(models.Model): title = models.CharField(max_length=250) is_favourite = models.BooleanField(default=False) def save(self, *args, **kwargs): if self.is_favourite: super(RedditLink, self).save(*args, **kwargs) I made my own save because I only need links that are favorite in my database. In addition, I have multiple reddit links on my search page to save. So how to handle multiple forms of the same model in django? The answer is to use Fromset. What is it? It is module provided by django for creation multiple forms. How to use it? Look at forms.py: from django import forms from .models import RedditLink RedditAddToFavouritesFormset = forms.modelformset_factory( RedditLink, fields=('title', 'is_favourite'), extra=5 ) I used something called forms.modelformset_factory which is a function to produce fromset from model. So I provided model name with fields to calling this function. What is more, I add additional argument extra for creating more than one form in formset. How to use newly created RedditAddToFavouritesFormset? … -
Ports and Adapters in python - part three
Third part of series about Django application made using Ports and Adapters design pattern. -
Custom python-social-auth Pipeline
Sometimes when you authenticate with a social service you need to do custom "stuff" in your code base beyond creating a user object. Learn how to get started simply adding a custom function do the python-social-auth pipeline.Watch Now... -
What We’re Clicking - May Link Roundup
Below you can find this month’s roundup of articles and posts shared by Cakti that drew the most attention on Twitter. The list covers coding for matrix factorization algorithms in Python, designing apps that optimize for sequential dual screen usage, preventing technical debt, and understanding the complexities and limitations involved in building apps for low-income American families. -
Google Analytics Graphs to your Dashboard in Python Web Frameworks
Ecommerce solution providers like OpenCart, Magento Provide extensions to see Google analytics data in their own dashboards as graphs. whereas there are no such plugins availble in Python. In this tutorial, we will learn how to display google graphs in your website. Open Google Developers Console, Create a new project or open existing project. enable google analytics API. create a service account and generate a JSON Key File. Use the below function to generate access token for analytics in read only mode. Python: from oauth2client.client import SignedJwtAssertionCredentials import json def get_access_token(): ''' Get Access Token From GOOGLE''' SCOPE = 'https://www.googleapis.com/auth/analytics.readonly' KEY_FILEPATH = <location to key file> with open(KEY_FILEPATH) as key_file: key_data = json.load(key_file) credentials = SignedJwtAssertionCredentials( key_data['client_email'], key_data['private_key'], SCOPE) return credentials.get_access_token().access_token you need to pass Google UserID and Google Acess Token to template. Javascript: //script to load analytics <script> (function(w,d,s,g,js,fs){ g=w.gapi||(w.gapi={});g.analytics={q:[],ready:function(f){this.q.push(f);}}; js=d.createElement(s);fs=d.getElementsByTagName(s)[0]; js.src='https://apis.google.com/js/platform.js'; fs.parentNode.insertBefore(js,fs);js.onload=function(){g.load('analytics');}; }(window,document,'script')); </script> //script to show graphs <script> gapi.analytics.ready(function() { gapi.analytics.auth.authorize({ 'serverAuth': { 'access_token': "{{google_access_token}}" } }); var dataChart1 = new gapi.analytics.googleCharts.DataChart({ query: { 'ids': '{{google_userid}}', 'start-date': '30daysAgo', 'end-date': 'today', 'metrics': 'ga:sessions', 'dimensions': 'ga:date', 'sort': '-ga:date' }, chart: { 'container': 'chart-1-container', 'type': 'LINE', 'options': { 'width': '100%' } } }); dataChart1.execute(); //To change when selectbox value is … -
Ports and Adapters in python - part two
Last time I wrote about how to do simple port & adapter in python. In this post, I will show to actually use them. I briefly remind you what is purpose of application build in this series: user will log in, then search with keyword so he can save any search result to database for read it later. I decided to first implement search mechanism for Reddit. This is what I will write today. Search request will be sent via GET. First, I need some form to handle this: 1 from django import forms 2 from django.conf import settings 3 4 from external_api.external_api_port import instantiated_port 5 6 class RedditSearchForm(forms.Form): 7 query = forms.CharField(label='search query', max_length=100) 8 9 def perform_search(self): 10 search_result = instantiated_port.search(self.cleaned_data['query']) 11 return search_result I defined simple form that has only one field: query which is CharField field with label. My form has one method perform_search. In this method, I import instantiated reddit port that takes instance of reddit adapter with settings from django settings module. Idealy this adapter should be singleton class. This is how it looks in reddit_adapter: from django.conf import settings # reddit adapter class here ... instantiated_adapter = RedditAdapter( settings.REDDIT_CLIENT_ID, settings.REDDIT_CLIENT_SECRET, settings.REDDIT_USERNAME, settings.REDDIT_PASSWORD ) … -
Ports and Adapters in python - part two
Last time I wrote about how to do simple port & adapter in python. In this post, I will show to actually use them. I briefly remind you what is purpose of application build in this series: user will log in, then search with keyword so he can save any search result to database for read it later. I decided to first implement search mechanism for Reddit. This is what I will write today. Search request will be sent via GET. First, I need some form to handle this: 1 from django import forms 2 from django.conf import settings 3 4 from external_api.external_api_port import instantiated_port 5 6 class RedditSearchForm(forms.Form): 7 query = forms.CharField(label='search query', max_length=100) 8 9 def perform_search(self): 10 search_result = instantiated_port.search(self.cleaned_data['query']) 11 return search_result I defined simple form that has only one field: query which is CharField field with label. My form has one method perform_search. In this method, I import instantiated reddit port that takes instance of reddit adapter with settings from django settings module. Idealy this adapter should be singleton class. This is how it looks in reddit_adapter: from django.conf import settings # reddit adapter class here ... instantiated_adapter = RedditAdapter( settings.REDDIT_CLIENT_ID, settings.REDDIT_CLIENT_SECRET, settings.REDDIT_USERNAME, settings.REDDIT_PASSWORD ) … -
Ports and Adapters in python - part two
Second part of series about Django application made using Ports and Adapters design pattern. -
Speed Comparison: Putting Pyston and PyPy to the Test
The most famous quote to characterize python speed is: It is fast enough I have used this quote many times, and I still believe that it applies to most circumstances if you throw enough hardware at the problem. Despite Python being “fast enough” for most applications, a few projects are working on making it even faster. The most well known is PyPy. It has been under active development for nearly a decade and is a production-ready implementation of the CPython API. In the last couple years, a competing project named Pyston has been seeing regular development and improvements. They're backed by Dropbox who has every reason to prioritize speed (considering that they manage massive amounts of code). They've also employed Guido van Rossum, the creator of Python, since 2012. Both Pyston and PyPy promise to deliver a faster Python Virtual Machine. They are doing so by applying a technique that has proven to be extremely efficient in JavaScript-land. This method is called "Just In Time compilation." Here's what the Pyston team team writes to explain their initiative: There are already a number of Python implementations using JIT techniques, often in sophisticated ways. PyPy has achieved impressive performance with its tracing … -
Evennia in pictures
Evennia in picturesby Griatch, September 2015This article was originally written for Optional Realities. Since it is no longer available to read on OR, I'm reposting it in full here. The MU* development system Evennia works quite differently from many traditional MU* code bases/servers and we get questions about this from time to time. This article will try to give an overview for outsiders - using pictures! Figure 1: The parts of the Evennia library Evennia is a game development library. What you see in Figure 1 is the part you download from us. This will not run on its own, we will soon initialize the missing “jigsaw puzzle” piece on the left. But first let’s look at what we’ve got. Looking at Figure 1 you will notice that Evennia internally has two components, the Portal and the Server. These will run as separate processes. The Portal tracks all connections to the outside world and understands Telnet protocols, websockets, SSH and so on. It knows nothing about the database or the game state. Data sent between the Portal and the Server is protocol-agnostic, meaning the Server sends/receives the same data regardless of how the user is connected. Hiding behind the Portal also … -
Sending emails using sendgrid on heroku for a Django App
You can send automated email campaigns in a simple and easy manner by using Sendgrid on Heroku for your Django App. Installation: First, you need to deploy your Django app on Heroku and then you can directly add Sendgrid to your Heroku application from Heroku ADD-ONS. Or You can integrate sendgrid add-on directly from your terminal by using Heroku CLI(Heroku Command Line). So, first you should install Heroku Toolbelt. Heroku Toolbelt Installation: wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh You can directly specify the above line in your terminal for installing Heroku Toolbelt. Heroku Version: Check your heroku version, to verify whether toolbelt is installaed or not. $ heroku --version heroku-toolbelt/3.43.3 (x86_64-linux) ruby/1.9.3 To Know Heroku File Location: By using 'which' command you can see your Heroku file location easily. $ which heroku /usr/local/heroku/bin/heroku Heroku Login: Login to heroku API by using your login creadentials like email and password and these details will be saved for future purpose. $ heroku login Enter your Heroku credentials. Email: user@heroku.com Password: After logged into heroku CLI you can add heroku add-ons by using below command: $ heroku addons:create sendgrid:starter How to get Sendgrid Username & Password: Once sendgrid has been successfully added to your Heroku, … -
Mastering Python
Mastering Python is finally out and available in your local book store. If you are an experienced Python developer, this might be the book for you. It will teach you the useful new features in Python 3 (currently up to 3.5) and show you a lot of Python tricks that you may not have seen before. As a Python developer with many years of experience I can guarantee you that you will learn something new. Quite a few sections result from original research which currently cannot (believe me, I’ve tried) be found online. Some of the more interesting subjects that are covered are asyncio and coroutines. Additionally, have you ever tried to apply the lambda calculus to Python? Give it a try, here’s the Quicksort algorithm using the Y combinator: >>> Y = lambda f: lambda *args: f(Y(f))(*args) >>> quicksort = Y(lambda f: ... lambda x: ( ... f([item for item in x if item < x&#91;0&#93;&#93;) ... + &#91;y for y in x if x&#91;0&#93; == y&#93; ... + f(&#91;item for item in x if item > x[0]]) ... ) if x else []) Link to this post! -
Code, Code, Code
I'm often asked by new programmers how they can forge a path into using their skills professionally. Or how they can get better at writing software. How to Improve Your Coding Skills This was my path. It may not be your path. I coded. A lot. From silly little scripts to automating tasks to attempting full-blown projects. At work or for fun. I failed a lot, but learned along the way. I didn't jump from language to language. Instead I stayed in a few places for years and focused my learning on those tools. My 19+ year career can be summed up as FoxPro then Java then Python. In the middle of things I picked up JavaScript. Sure, I've dallied with a few things (Lisp, Haskell, Lua, Perl, ColdFusion, Go), but by staying focused on a small set of tools I'm better than mediocre. I coded lots. Yes, this is a repeat of #1. Once I got the basics of a language, I looked up best practices for each of them. Then I religiously adhered to them, even becoming dogmatic about it. In general this means my code is more easily read. More easily debugged. And most importantly, more easily … -
Code, Code, Code
I'm often asked by new programmers how they can forge a path into using their skills professionally. Or how they can get better at writing software. How to Improve Your Coding Skills This was my path. It may not be your path. This path also isn't in any particular order, all of them apply from the moment you start on the path. I coded. A lot. From silly little scripts to automating tasks to attempting full-blown projects. At work or for fun. I failed a lot, but learned along the way. I didn't jump from language to language. Instead I stayed in a few places for years and focused my learning on those tools. My 19+ year career can be summed up as FoxPro then Java then Python. In the middle of things I picked up JavaScript. Sure, I've dallied with a few things (Lisp, Haskell, Lua, Perl, ColdFusion, Go), but by staying focused on a small set of tools I'm better than mediocre. I coded lots. Yes, this is a repeat of #1. Once I got the basics of a language, I looked up best practices for each of them. Then I religiously adhered to them, even becoming dogmatic … -
Code, Code, Code
I'm often asked by new programmers how they can forge a path into using their skills professionally. Or how they can get better at writing software. How to Improve Your Coding Skills This was my path. It may not be your path. This path also isn't in any particular order, all of them apply from the moment you start on the path. I coded. A lot. From silly little scripts to automating tasks to attempting full-blown projects. At work or for fun. I failed a lot, but learned along the way. I didn't jump from language to language. Instead I stayed in a few places for years and focused my learning on those tools. My 19+ year career can be summed up as FoxPro then Java then Python. In the middle of things I picked up JavaScript. Sure, I've dallied with a few things (Lisp, Haskell, Lua, Perl, ColdFusion, Go), but by staying focused on a small set of tools I'm better than mediocre. I coded lots. Yes, this is a repeat of #1. Once I got the basics of a language, I looked up best practices for each of them. Then I religiously adhered to them, even becoming dogmatic …