Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Fast Application Development with Django Starters
If you have been working in the software industry for many years you will probably know that one of the principles in development is reuse. Specifically, in Django we have some design philosophies: Less Code Quick Development Don’t repeat yourself Usually developers apply these principles to the code they write, so when they begin a new application they begin to import all the modules needed for the construction and to make all the configuration required. When constructing an application from scratch they always have to repeat a long sequence of almost identical steps, and wrongly, most developers think that there is not an alternative to this behaviour. There is a much better alternative and it is provided by Django. We call it “Starters” and in the next technical posts we will explain how to get your own Starter, but in this one, we will talk about the advantages that Starters bring for our products and clients. The starters are templates of different base projects which have a set of predefined features that we can implement in a record time to begin to develop the prototype or the final solution for our clients. We obtain a set of very interesting benefits … -
Fast Application Development with Django Starters
If you have been working in the software industry for many years you will probably know that one of the principles in development is reuse. Specifically, in Django we have some design philosophies: Less Code Quick Development Don’t repeat yourself Usually developers apply these principles to the code they write, so when they begin a new application they begin to import all the modules needed for the construction and to make all the configuration required. When constructing an application from scratch they always have to repeat a long sequence of almost identical steps, and wrongly, most developers think that there is not an alternative to this behaviour. There is a much better alternative and it is provided by Django. We call it “Starters” and in the next technical posts we will explain how to get your own Starter, but in this one, we will talk about the advantages that Starters bring for our products and clients. The starters are templates of different base projects which have a set of predefined features that we can implement in a record time to begin to develop the prototype or the final solution for our clients. We obtain a set of very interesting benefits … -
Python Datetime Get Month Ranges
Every once and a while you nee... -
How To Install Django Debug Toolbar
The Django Debug Toolbar is a configurable set of panels that display various debug information about the current request/response and when clicked, display more details about the panel's content. For the installation of the Django Debug Toolbar you need to have a django project where you can use pip in a Virtual Environment or without them. If you wan’t use pip, you can get the code of this component from here (https://github.com/jazzband/django-debug-toolbar) and put it in your django project path. But is more easy the pip installation and we will focus on this. For installation we recommend use the virtual env and execute this command: pip install django-debug-toolbar The configuration of this component is simple, but because most of the configuration must be done in the core of the settings of the project, we recommend to do it independently. First, in your general project urls.py, enter this code: from django.conf import settings from django.conf.urls import include, url if settings.DEBUG: import debug_toolbar urlpatterns += [ url(r'^__debug__/', include(debug_toolbar.urls)), ] Take care with the “imports” because it’s possible that you duplicate some of this. In the settings.py we enter our independent conf for this component, like this: DEBUG = True if DEBUG: INTERNAL_IPS … -
Django 101 – Proje Kurulumu #1
Video Icerisindekiler: – Onerilen dosyalama yapisi. – Onerdigim dokumantasyon kaynaklari. – Proje dizini olusturulmasi ve gerekliliklerin eklenmesi. – Django projesi olusturulmasi. -
Django 101 – Proje Kurulumu #1
Video Icerisindekiler: – Onerilen dosyalama yapisi. – Onerdigim dokumantasyon kaynaklari. – Proje dizini olusturulmasi ve gerekliliklerin eklenmesi. – Django projesi olusturulmasi. -
MVC Nedir ? (Django – MVT)
Model-View-Controler yani MVC yapisi ve kullanim amaci nedir. Django icin MVT yapisi ve calisma mekanizmasi. -
MVC Nedir ? (Django – MVT)
Model-View-Controler yani MVC yapisi ve kullanim amaci nedir. Django icin MVT yapisi ve calisma mekanizmasi. -
Virtualenv Nedir ve Nasıl Kullanılır
Bu ilk videom olduğu için bazı hatalarım olduğunu fark etmemek mümkün değil. Şimdilik bu hatalarla bu video yayınlamaya ve sonraki içeriklerde daha dikkatli olmaya çalışacağım. Virtualenv Nedir ve Nasıl Kullanılır yazısı ilk önce Python Türkiye üzerinde ortaya çıktı. -
How To Install Django-LocalFlavor
Package of the week: LocalFlavor Have you ever had to develop a web application with unique fields depending on the country to which the user is focused or to which the user belongs? The solution to these problem is a package called Django-localflavor, as the same documentation says: ‘’django-localflavor is a collection of assorted pieces of code that are useful for particular countries or cultures’’. It is a very easy to use package that we have used in BeDjango with great results and we will try to explain it briefly Installation This package is really easy to install: pip install django-localflavor Then add ‘localflavor’ to your INSTALLED_APPS setting: INSTALLED_APPS = ( # ... 'localflavor', ) Countries fields Currently the package has specific fields for the following list of countries, although they accept new issues and PR in their repository in github Argentina (ar) Austria (at) Australia (au) Belgium (be) Bulgaria (bg) Brazil (br) Canada (ca) Switzerland (ch) Chile (cl) China (cn) Colombia (co) Czech Republic (cz) Germany (de) Denmark (dk) Ecuador (ec) Estonia (ee) Spain (es) Finland (fi) France (fr) Great Britain (gb) Greece (gr) Hong Kong (hk) Croatia (hr) Hungary (hu) Indonesia (id) Ireland (ie) Israel (il) India (in) … -
Tips and Tricks for Improved Django Security: published
In this article we shall discuss a point to which we give little importance when we are beginning to programme our application and which, with little details, we can improve significantly. Security! Nowadays, there are many methods through which a website may find itself in risk of being attacked, in the following link we can see the TOP 10 most common risks according to OWASP. Next, we'll give you a few pieces of advice about security without mentioning those shown on the official django website. Wappalyzer is an extension which identifies the software running on our website, which allows some bots to exploit known bugs before we can patch our website, for which reason it is advisable to protect our website from this type of extension. In our case, django is detected by the “csrfmiddlewaretoken” whose name we can change, and whose information we can amplify, by following the subsequent guide hide-django-from-wappalyzer. One of the strengths of django is the administration panel, which we can reach by using the default url */admin. A way of hiding this panel and avoiding brute-force attacks is to change this url, which is as a simple as modifying the file urls.py and substituting: # Default … -
Django + Chart.js
Learn how to integrate Charts.... -
How to Crop Images in a Django Application
Cropping images is a fairly common use case in a Web application. For example, some applications let you upload a profile picture. In addition, it usually also let you crop and resize the image for a better result. Unfortunately, when dealing with image processing we need to install a few dependencies, both in the front-end and in the back-end. In this tutorial I will demonstrate how to upload an image, display a preview in a modal, crop the image and finally upload it and save in the server. If you are not familiar with file upload in Django, check this post for a quick reference: How to Upload Files With Django. Installing Dependencies In the following example I will be using: Python 3.6.0 Django 1.10.5 Pillow 4.0.0 jQuery 3.1.1 Cropper v3.0.0-beta Within your project directory or virtualenv, install Pillow: pip install Pillow I know, I know… Sometimes installing Pillow is a nightmare. If you face any problem installing it locally, please refer to the Pillow’s Installation Guide. The jQuery utility to crop images in the Web browser can be downloaded here. Or if you prefer to use it’s pure JavaScript version, download Cropper.js here. But please note that in the … -
Tracking the Results of Cron Jobs
Every Django website needs some automatic background tasks to execute regularly. The outdated sessions need to be cleaned up, search index needs to be updated, some data needs to be imported from RSS feeds or APIs, backups need to be created, you name it. Usually, if not all the time, those regular tasks are being set as cron jobs. However, when some task is run in the background, by default, you don't get any feedback whether it was successfully completed, or whether it crashed on the way. In this post I will show you how I handle the results of cron jobs. In a Django project, all those tasks are usually implemented as management commands. For each such command I write a short bash script, that will call the management command with specific parameters and will print the verbose output to a log file. Let's say my project structure is like this on a remote server: /home/myproject├── bin├── include├── lib├── public_html├── backups├── project│ └── myproject├── scripts└── logs A virtual environment is created in the home directory of myproject linux user. The Django project itself is kept under project directory. The scripts directory is for my bash scripts. And the logs … -
Build Facebook messenger bots with Python and Django
Throughout this tutorial ,we are going to see how to build a Facebook messenger bot using Python and Django framework . The Facebook messenger platform is one of the biggest platforms for messaging on the Internet in these days . If you are a business and your have a Facebook page that it might be a good idea to provide your users with an automatic method to get some answers such as the frequently asked questions that get asked all the time by customers but you can also build more advanced bots that use artificial intelligence (AI) . Here is a list of the best messenger bots Also watch this video from CNNMoney which talks about how Messenger Bots can replace customer service for brands You'll learn how to build a simple Facebook bot step by step .The bot will not use any advanced AI algorithms but only a simple IF based statements so you need to have some knowledge about Python language and Django framework . Creating a Facebook app A Facebook bot is just another type of Facebook apps so we need to create a Facebook app for our bot . Simply go to Facebook developers website then … -
Django deployment webinar starting soon
Today on 16:00 UTC I’m hosting a webinar. Deploying Django: From zero to production in 20 minutes. I’m sorry about the late notice. I’ve announced it on many places and it has generated quite some interest, but it occured to me that some people who are monitoring this blog might not see it elsewhere. See you on the webinar. The post Django deployment webinar starting soon appeared first on Django deployment. -
Django Admin and Celery
A weird race condition Some background: We have a model that is edited only via the Django admin. The save method of the model fires a celery task to update several other records. The reason for using celery here is that the amount of related objects can be pretty big and we decided that it is best to spawn the update as a background job. We have unit and integration tests, the code was also manually tested, everything looked nice and we deployed it. On the next day we found out that the code is acting weird. No errors, everything looked like it has worked but the updated records actually contained the old data before the change. The celery task accepts the object ID as an argument and the object is fetched from the database before doing anything else so the problem was not that we were passing some old state of the object. Then what was going on? Trying to reproduce it: Things are getting even weirder. The issues is happening every now and then. Hm...? Race condition?! Let's take a look at the code: class MyModel(models.Model): def save(self, **kwargs): is_existing_object = False if self.pk else True super(MyModel, self).save(**kwargs) … -
You Sould do Weird Stuff in Django
Out of the ordinary things are the times that we grow the most as developers. However, a lot of times we don't do enough weird things when we write our software. I would encourage you to try that odd idea that you have been messing with in your head that you aren't sure you can do. Ironically you will grow more as a developer from that than your day to day getting stuff done development I am not sure why I ever really thought about this, but give a watch to what keyed me in on this thought. You Should Do Weird Stuff in Django -
Install Django on Mac OS or Linux
# Install Django & Virtualenv ... -
How to build a classified web app with Django
Throughout this tutorial series we are going to build a classified website with Django framework starting from the very first step which is the setup and configuration of development environment to the final step . The resulting project will be hosted on GitHub with an MIT license so feel free to fork or clone it if you need a ready project for tweaking but you’ll need to apply your own CSS styles because it only has minimal styling with Bootstrap framework . If you want to learn how to build your own classified web application from scratch using Python and Django just make sure you follow these series from the start till the end . Getting started with a Django project This tutorial assumes you have already Python and Django installed on your machine . Also i’m developing under a Ubuntu system so the commands and instructions in this tutorial are designed for Ubuntu but you should be able to follow the same steps on MAC or using the command prompt on Windows . So go ahead and create a new virtual environment for our project . Open up the terminal and navigate to your desired location then type virtualenv … -
Make Your Developer's Life Easier By Reducing Number Of Opened Tabs in Pycharm
When coding, I often find myself overwhelmed by a number of opened tabs in my editor. I just seem to have opened every single .py file of a Django project. And it's kinda hard to find a way in this evergrowing of tabs. Given that, I was really happy to ... Read now -
Python type annotations
When it comes to programming, I have a belt and suspenders philosophy. Anything that can help me avoid errors early is worth looking into. -
New in Django 1.11: Template-based widget rendering
There's a very interesting change coming with Django 1.11 - To make customizing widgets easier, form widget rendering is now done using the template system. In older versions, widgets were rendered using Python. You can get more details about it from The form rendering API docs page: https://docs.djangoproject ... Read now -
Mercurial Mirror For Django 1.11 Branch
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.11-production/ -
How to Add reCAPTCHA to a Django Site
Google’s reCAPTCHA is a very popular solution to protect your application or website against bots and spam. It is fairly simple to implement. In this tutorial you will find a working example using only built-in libraries, an alternative using requests and also an implementation using decorators, to reuse the reCAPTCHA verification across your application. Setup First thing, register your application in the reCAPTCHA admin. I added the 127.0.0.1 IP address as my domain for testing purpose. Here you are supposed to add your website domain. After registering your website, you will be handed a Site key and a Secret key. The Site key will be used in the reCAPTCHA widget which is rendered within the page where you want to place it. The Secret key will be stored safely in the server, made available through the settings.py module. settings.py GOOGLE_RECAPTCHA_SECRET_KEY = '6LdRSRYUAAAAAOnk5yomm1dI9BmQkJWTg_wIlMJ_' PS: It is not a good idea to keep this kind of information directly in the settings.py. I’m adding it here so the example is more explicit. Please refer to this article Package of the Week: Python Decouple to learn how to separate configuration from settings, and keep sensitive information in a safe place. Implementing the reCAPTCHA Let’s …