Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Using Python with Electron Tutorial
In this tutorial, you'll learn to build GUIs for your Python applications using Electron and web technologies i.e HTML, CSS and JavaScript-this means taking advantage of the latest advancements in front-end web development to build desktop applications but also taking advantages of Python and the powerful libraries it has to easily implement advanced requirements. You can find the code in this GitHub repository. Electron Tutorial Electron allows you to develop desktop applications with web technologies such as JavaScript, HTML and CSS by providing a web container and a runtime with rich native cross-platform APIs. You could also think of it as a Node.js environment for desktop apps. Electron Applications Architecture In Electron, you have two types of processes; the Main and Renderer processes. The main process is the one that runs the main script in the package.json file. This script can create and display GUI windows, also many Electron APIs are only available from the main process. An Electron application has always only one main process. Electron makes use of the chromium browser to display web pages. Each web page runs on its own process called the renderer process. You could also think of Electron as a web browser but … -
Stop Using Executable Code Outside of Version Control
There's an anti-pattern in the development world, and it's for using executable code as a means to store configuration values. In the Python universe, you sometimes see things like this in settings modules: # Warning: This is an anti-pattern! try: from .local_settings import * except ImportError: pass What people do is have a local_settings.py file that has been identified in a .gitignore file. Therefore, for local development you have your project running through an executable code file outside of version control. If this sounds uncomfortable to you, then you are on the right track. Executable code always needs to be in version control. A better approach is to place secrets and keys into environment variables. If you don't like that, or can't use it due to your environment, stick those values into JSON, YAML, or TOML files. So what can happen if you allow the local_settings anti-pattern into your project? The local_settings anti-pattern The local_settings anti-pattern means that you can have executable code in production that usually can't be viewed by developers trying to debug problems. If you've ever experience it, this is one of the worst production debugging nightmares. It worked fine on my laptop! What works locally and … -
Why You Should Consider Adding Voice Technology to Your App
Voice technology is here to stay. We’ve invited smart speakers such as the Amazon Echo, Google Home, Sonos One, and Apple HomePod into our homes and our workplaces. We talk to Siri, Alexa, Cortana, and Google Assistant nearly as easily as we talk to real humans. The trends are clear: Consumers are embracing voice technology, and they’re excited about products and devices that incorporate voice-enabled capabilities. The post Why You Should Consider Adding Voice Technology to Your App appeared first on Distillery. -
Why You Should Consider Adding Voice Technology to Your App
Voice technology is here to stay. We’ve invited smart speakers such as the Amazon Echo, Google Home, Sonos One, and Apple HomePod into our homes and our workplaces. We talk to Siri, Alexa, Cortana, and Google Assistant nearly as easily as we talk to real humans. The trends are clear: Consumers are embracing voice technology, and they’re excited about products and devices that incorporate voice-enabled capabilities. The post Why You Should Consider Adding Voice Technology to Your App appeared first on Distillery. -
Inline building in upcoming Evennia 0.8
Evennia, the Python MUD-server game development kit, is slowly creeping closer to its 0.8 release.In our development branch I've just pushed the first version of the new OLC (OnLine Creator) system. This is a system to allow builders (who may have limited coding knowledge) to customize and spawn new in-game objects more easily without code access. It's started with the olc command in-game. This is a visual system for manipulating Evennia Prototypes.Briefly on PrototypesThe Prototype is an Evennia concept that has been around a good while. The prototype is a Python dictionary that holds specific keys with values representing properties on a game object. Here's an example of a simple prototype:{"key": "My house", "typeclass": "typeclasses.houses.MyHouse"} By passing this dict to the spawner, a new object named "My house" will be created. It will be set up with the given typeclass (a 'typeclass' is, in Evennia lingo, a Python class with a database backend). A prototype can specify all aspects of an in-game object - its attributes (like description and other game-specific properties), tags, aliases, location and so on. Prototypes also support inheritance - so you can expand on an existing template without having to add everything fresh every time. There … -
Distillery Makes the Inc. 5000 — for the Second Year in a Row!
We’re elated to announce that Distillery has again been honored on the Inc. 5000! The 2018 ranking, published August 15, revealed that Distillery’s growth is holding strong, earning us a place on the prestigious list for the second year running. (Last year marked Distillery’s impressive debut as a member of the lnc. 5000.) We couldn’t be more thrilled about the recognition, as it testifies to the fact that all our hard work, investments, and persistence over the past year are continuing to take our company in the right direction. The post Distillery Makes the Inc. 5000 — for the Second Year in a Row! appeared first on Distillery. -
Distillery Makes the Inc. 5000 — for the Second Year in a Row!
We’re elated to announce that Distillery has again been honored on the Inc. 5000! The 2018 ranking, published August 15, revealed that Distillery’s growth is holding strong, earning us a place on the prestigious list for the second year running. (Last year marked Distillery’s impressive debut as a member of the lnc. 5000.) We couldn’t be more thrilled about the recognition, as it testifies to the fact that all our hard work, investments, and persistence over the past year are continuing to take our company in the right direction. The post Distillery Makes the Inc. 5000 — for the Second Year in a Row! appeared first on Distillery. -
django-pipeline and Zopfli
tl;dr; I wrote my own extension to django-pipeline that uses Zopfli to create .gz files from static assets collected in Django. Here's the code. Nginx and Gzip What I wanted was to continue to use django-pipeline which does a great job of reading a settings.BUNDLES setting and generating things like /static/js/myapp.min.a206ec6bd8c7.js. It has configurable options to not just make those files but also generate /static/js/myapp.min.a206ec6bd8c7.js.gz which means that with gzip_static in Nginx, Nginx doesn't have to Gzip compress static files on-the-fly but can basically just read it from disk. Nginx doesn't care how the file got there but an immediate advantage of preparing the file on disk is that the compression can be higher (smaller .gz files). That means smaller responses to be sent to the client and less CPU work needed from Nginx. Your job is to set gzip_static on; in your Nginx config (per location) and make sure every compressable file exists on disk with the same name but with the .gz suffix. In other words, when the client does GET https://example.com/static/foo.js Nginx quickly does a read on the file system to see if there exists a ROOT/static/foo.js.gz and if so, return that. If the files doesn't exist, … -
JavaScript ES6 Tutorial for Django Developers
This JavaScript (ES6) tutorial is a part to a series of tutorials to teach Django developers front-end web development for creating modern full-stack applications. Before starting the tutorial for the new JavaScript/ES6 features, we will first learn how to include JavaScript in a Django project. There are two methods of integrating JavaScript with Django. Separate Django (back-end) and JavaScript(front-end) apps which is convenient for building JavaScript-heavy apps with a Django RESTful back-end Using JavaScript with Django built-in templates which is convenient for apps that don't need a complex JavaScript front-end We've previously covered how to use the first approach with React, Vue and Angular examples. In this tutorial, we'll focus on the second approach. We assume, you already have created a project. Check this tutorial if you need help! Let's start by creating a Django HTML base template for your application (base.html): <!DOCTYPE html> <html lang="en"> <head> {% block title %}<title>Django JavaScript ES6 Tutorial</title>{% endblock %} <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> {% block body %} {% endblock %} </body> </html> Adding JavaScript to Our Django Template We can add JavaScript to our template using an inline <script> tag or an external JavaScript file. Let's create a app.js … -
Django lock decorator with django-redis
Here's the code. It's quick-n-dirty but it works wonderfully: import functools import hashlib from django.core.cache import cache from django.utils.encoding import force_bytes def lock_decorator(key_maker=None): """ When you want to lock a function from more than 1 call at a time. """ def decorator(func): @functools.wraps(func) def inner(*args, **kwargs): if key_maker: key = key_maker(*args, **kwargs) else: key = str(args) + str(kwargs) lock_key = hashlib.md5(force_bytes(key)).hexdigest() with cache.lock(lock_key): return func(*args, **kwargs) return inner return decorator How To Use It This has saved my bacon more than once. I use it on functions that really need to be made synchronous. For example, suppose you have a function like this: def fetch_remote_thing(name): try: return Thing.objects.get(name=name).result except Thing.DoesNotExist: # Need to go out and fetch this result = some_internet_fetching(name) # Assume this is sloooow Thing.objects.create(name=name, result=result) return result That function is quite dangerous because if executed by two concurrent web requests for example, they will trigger two "identical" calls to some_internet_fetching and if the database didn't have the name already, it will most likely trigger two calls to Thing.objects.create(name=name, ...) which could lead to integrity errors or if it doesn't the whole function breaks down because it assumes that there is only 1 or 0 of these Thing … -
Comparing AWS vs Azure vs Google Cloud Platforms For Enterprise App Development
Enterprise companies around the world have made the switch from self-hosted infrastructure to public cloud configurations. While most enterprises will always need some on-premise technology, they are developing their applications directly in the cloud. This allows the development teams to stay product focused, rather than having to work on the infrastructure to support the application. By moving to the cloud, enterprises have an existing physical infrastructure that is continuously maintained and updated. This gives them more resources and time to dedicate to the mobile app development project at hand. The post Comparing AWS vs Azure vs Google Cloud Platforms For Enterprise App Development appeared first on Distillery. -
Comparing AWS vs Azure vs Google Cloud Platforms For Enterprise App Development
Enterprise companies around the world have made the switch from self-hosted infrastructure to public cloud configurations. While most enterprises will always need some on-premise technology, they are developing their applications directly in the cloud. This allows the development teams to stay product focused, rather than having to work on the infrastructure to support the application. By moving to the cloud, enterprises have an existing physical infrastructure that is continuously maintained and updated. This gives them more resources and time to dedicate to the mobile app development project at hand. The post Comparing AWS vs Azure vs Google Cloud Platforms For Enterprise App Development appeared first on Distillery. -
Django vs WordPress: How to decide?
In the early stages of a web development project, your first step is a big decision: what’s the right tool for the job? What kind of software makes the most sense for me? A lot of our clients come to us at this stage, seeking advice on how to approach this decision. And it’s an important one: once you invest in a particular platform, the cost to switch later may be high. You’ll want to make sure you have all the info before making your decision. Should you use WordPress or Django? To answer that question, I first need to explain what each of these systems are because we’re actually talking apples and oranges, or maybe apples and fruit salads. When people say WordPress, they’re referring to the content management system (CMS) that’s used to create and upload the website content. Basically, WordPress is the dashboard through which you organize text and images to display on your website. WordPress is built using the PHP programming language. Django, on the other hand, is what’s called a web framework. Built on the powerful Python programming language, it’s a set of tools and libraries that can be rapidly deployed to build custom web … -
Django vs WordPress: How to decide?
In the early stages of a web development project, your first step is a big decision: what’s the right tool for the job? What kind of software makes the most sense for me? A lot of our clients come to us at this stage, seeking advice on how to approach this decision. And it’s an important one: once you invest in a particular platform, the cost to switch later may be high. You’ll want to make sure you have all the info before making your decision. Should you use WordPress or Django? To answer that question, I first need to explain what each of these systems are because we’re actually talking apples and oranges, or maybe apples and fruit salads. When people say WordPress, they’re referring to the content management system (CMS) that’s used to create and upload the website content. Basically, WordPress is the dashboard through which you organize text and images to display on your website. WordPress is built using the PHP programming language. Django, on the other hand, is what’s called a web framework. Built on the powerful Python programming language, it’s a set of tools and libraries that can be rapidly deployed to build custom web … -
How to customize the admin actions in list pages of Django admin?
Django by default provides automatic admin interface, that reads metadata from your models to provide a beautiful model interface where trusted users can manage content on your site. The admin is enabled in the default project template used by startproject so we don't need to worry of the settings. By default the model won't get displayed in the admin panel, to make the models of our application visible in the admin panel we have to regsiter the models in admin.py with admin. In models.py STATUS_CHOICES = ( ('d', 'Draft'), ('p', 'Published'), ('r', 'Review'), ('t', 'Trash'), ) class BlogPost(models.Model): title = models.CharField(max_length=100) content = models.TextField() status = models.CharField(max_length=1, choices=STATUS_CHOICES) created_date = models.DateTimeField(auto_now_add=True) def __str__(self): return self.title In admin.py admin.site.register(BlogPost) Customizing the admin actions: When we register our app with the admin we’ll see the table in the admin panel. By default it will come with ‘delete selected’ action in the list page. Now we want to add some actions like Publish the selected posts or Draft the selected posts. then we would be override the ModelAdmin and write our … -
django-html-validator now supports Django 2.x
django-html-validator is a Django project that can validate your generated HTML. It does so by sending the HTML to https://html5.validator.nu/ or you can start your own Java server locally with vnu.jar from here. The output is that you can have validation errors printed to stdout or you can have them put as .txt files in a temporary directory. You can also include it in your test suite and make it so that tests fail if invalid HTML is generated during rendering in Django unit tests. The project seems to have become a lot more popular than I thought it would. It started as a one-evening-hack and because there was interest I wrapped it up in a proper project with "docs" and set up CI for future contributions. I kinda of forgot the project since almost all my current projects generate JSON on the server and generates the DOM on-the-fly with client-side JavaScript but apparently a lot of issues and PRs were filed related to making it work in Django 2.x. So I took the time last night to tidy up the tox.ini etc. and the necessary compatibility fixes to make it work with but Django 1.8 up to Django 2.1. … -
How to Use Bootstrap 4 Forms With Django
This is a quick tutorial to get you start with django-crispy-forms and never look back. Crispy-forms is a great application that gives you control over how you render Django forms, without breaking the default behavior. This tutorial is going to be tailored towards Bootstrap 4, but it can also be used with older Bootstrap versions as well as with the Foundation framework. The main reason why I like to use it on my projects is because you can simply render a Django form using `` and it will be nicely rendered with Bootstrap 4, with very minimal setup. It’s a really life saver. Installation Install it using pip: pip install django-crispy-forms Add it to your INSTALLED_APPS and select which styles to use: settings.py INSTALLED_APPS = [ ... 'crispy_forms', ] CRISPY_TEMPLATE_PACK = 'bootstrap4' Setup Bootstrap You can either download the latest Bootstrap 4 version at getbootstrap.com. In that case, go to download page and get the Compiled CSS and JS version. Or you can use the hosted Bootstrap CDN: <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script> For simplicity, I will be using the CDN version. Here is my base.html template that will be referenced in the following examples: <!doctype … -
How to Build a Unique Technology for Your Fintech Product with Python
Fintech is a maze. It’s a thrilling and extremely complex industry for software development. There are state level regulations, integrations with different services and institutions, bank API connections, etc. to deal with. Another challenge is the high level of trust from the end users required to run finance, mortgages, investments and such. These, in turn, require the highest level of security, functionality, and correspondence with requirements. What I’m trying to say is that the more unique the software is, the higher it’s valued. Without a properly working and trustworthy software, any financial venture will die down and lose worth. People need financial technology that will last, and I’m going to tell you how we achieved this with Python/Django technological stack while developing fintech products. It’s especially pleasant to say after Python has become the world’s most popular coding language. Fintech: The Importance of Being Unique In the world of finance, there are two streams that still coexist. On one hand, there are the millennials who stride gloriously into the future while mastering contactless payments, using on-line banking and all kinds of digital financing services. In an effort to avoid old school bureaucracy, they build their lives in a way that … -
4 Strategies for Integrating Voice Technology into Your Business
In the world of business, voice technology holds astonishing potential. It can transform how your people work, or how your customers interact with your business or buy your products. Smart businesses are starting to think about how they can use voice to improve their operations or their customer experience. The post 4 Strategies for Integrating Voice Technology into Your Business appeared first on Distillery. -
4 Strategies for Integrating Voice Technology into Your Business
In the world of business, voice technology holds astonishing potential. It can transform how your people work, or how your customers interact with your business or buy your products. Smart businesses are starting to think about how they can use voice to improve their operations or their customer experience. The post 4 Strategies for Integrating Voice Technology into Your Business appeared first on Distillery. -
Individual member of the Django Software Foundation
Last Saturday, somewhen late at night when we came back home from our trip to the city, I received an unexpected mail. I was nominated, seconded and approved to be an Individual Member of the Django Software Foundation. This came completely unexpected and honestly caught me a bit off guard. I let it sink in a bit and accepted the invitation on Sunday, with a nice glass of scotch next to me. I have been using Django since 0.96-svn or so and I have been using it to ship production software for a decade. (Yes, I was actually crazy enough to bet on a pre 1.0 release framework instead of TurboGears which was a bit more established, had a nicer ORM and some really nice JavaScript integration.) During all those years I experienced a warm, welcoming and inclusive community that is also able to talk tech. This is a very nice combination. I have seen communities which are also welcoming and inclusive but lacked the technical capabilities to drive a project forward. And I have seen technical capable communities I would not want to spent five minutes with in a room full of liquor. Django was and still is the … -
Individual member of the Django Software Foundation
Individual member of the Django Software Foundation Last Saturday, somewhen late at night when we came back home from our trip to the city, I received an unexpected mail. I was nominated, seconded and approved to be an Individual Member of the Django Software Foundation. This came completely unexpected and honestly caught me a bit off guard. I let it sink in a bit and accepted the invitation on Sunday, with a nice glass of scotch next to me. I have been using Django since 0.96-svn or so and I have been using it to ship production software for a decade. (Yes, I was actually crazy enough to bet on a pre 1.0 release framework instead of TurboGears which was a bit more established, had a nicer ORM and some really nice JavaScript integration.) During all those years I experienced a warm, welcoming and inclusive community that is also able to talk tech. This is a very nice combination. I have seen communities which are also welcoming and inclusive but lacked the technical capabilities to drive a project forward. And I have seen technical capable communities I would not want to spent five minutes with in a room full of … -
Hackathon 2018: Kegerator 2—Revenge of the Flowmeter
Hackathon 2018: Kegerator 2—Revenge of the Flowmeter Morgan Senkal Wed, 08/01/2018 - 21:25 Read more about Hackathon 2018: Kegerator 2—Revenge of the FlowmeterAdd new comment If you’re going to spend two long days frying a Raspberry Pi and fiddling with (very) finicky electronics, is there any better way to do it than surrounded by beer? -
Congratulations to NetCloak on Joining the Techstars LA Class of 2018!
Congratulations to NetCloak on their acceptance into the Techstars LA startup accelerator program! In this week’s announcement, the tech incubator lauded the incredible breadth and depth of talent in the local startup ecosystem. Having had the chance to work with NetCloak’s impressive leadership team and staff first-hand, we agree that the forward-looking enterprise cybersecurity startup is a fantastic addition to Techstars LA’s Class of 2018. The post Congratulations to NetCloak on Joining the Techstars LA Class of 2018! appeared first on Distillery. -
Congratulations to NetCloak on Joining the Techstars LA Class of 2018!
Congratulations to NetCloak on their acceptance into the Techstars LA startup accelerator program! In this week’s announcement, the tech incubator lauded the incredible breadth and depth of talent in the local startup ecosystem. Having had the chance to work with NetCloak’s impressive leadership team and staff first-hand, we agree that the forward-looking enterprise cybersecurity startup is a fantastic addition to Techstars LA’s Class of 2018. The post Congratulations to NetCloak on Joining the Techstars LA Class of 2018! appeared first on Distillery.