Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Reactify Django
# Reactify Django is Here Bui... -
Install Jupyter Notebooks in a Virtual Environment
Let's install Jupyter for a di... -
Setup React
Below is a reference we made t... -
A few JavaScript Functions for Images and Files
> This post will be updated as... -
Changing Default Python 3 in Terminal for Mac OS
Sometimes Python gets upgraded... -
Pipenv Virtual Environments for Python
`Pipenv` is an **amazing** rep... -
Deep Learning Acronym Cheatsheet
Below as a list I'm working on... -
Dataset Resources for Machine Learning
In our [Machine Learning](/cou... -
Serverless Django with Zappa on AWS Lambda
Going serverless with Django a... -
RDS Database for Serverless Django + Zappa on AWS Lambda
This is a critical piece of ha... -
Prepare AWS IAM User, Role, and Policies for Zappa and Serverless Python
This is [Zappa](https://www.za... -
Custom Domains for Zappa Projects
For web applications, a custom... -
Terminal Prompt Formatting
When you open up `Terminal` fo... -
Create a Blank Django Project
#### A how-to guide for creati... -
Django CRUD: Python 3.7 & Generic Class-Based Views
Throughout this tutorial, you'll create a Django CRUD example application using generic class based views. You will be using the latest Python 3.7 version. You'll learn to quickly create CRUD views by using the Django built-in generic views such as ListView, DetailView, CreateView, UpdateView and DeleteView. CRUD stands for create, read, update and delete and it simply refers to a set of common operations that are used in most web applications to interact with data from a database. It basically provides a CRUD interface that allows your users to create, read, update and delete data in your application database like MySQL, PostgreSQL or Oracle etc. Prerequisites You'll need to have the following prerequisites: A development machine with Python 3.7, pip and venv installed, A basic knowledge of Python, A working knowledge of Django. In this tutorial, you'll learn about: Django class based views, Creating and activating a virtual environment using venv, Installing Django using pip and creating a new project using django-admin.py, Creating a new Django application using manage.py, Creating a Django ORM model, Enabling the admin Interface, Creating the class based views, Creating the templates, Adding the URLs. Creating and Activating a Virtual Environment When working with new Python … -
How to implement TokenBasedAuthentication in DjangoRestFramework?
If you are new to Django REST framework, then you can go through below blog posts to understand how to develop RESTful API with Django REST framework. How to develop RESTful webservice in Django using Django REST framework Introduction to API development with Django REST framework Generic, Functional based and Class based views in Django REST Framework REST framework provides a number of authentication methods and also allows us to implement custom methods. This blog shows you how to use Token Authentication to authenticate users within a Django Application. Token Authentication is a way to authorize users by using an Auth Token. First, you have to add 'rest_framework.authtoken' to your INSTALLED_APPS setting as Token Authentication uses a special model called Token, which is used to store your user authentication tokens. INSTALLED_APPS = ( ... 'rest_framework', 'rest_framework.authtoken' ) Then you must configure the authentication scheme to include 'TokenAuthentication' using the 'DEFAULT_AUTHENTICATION_CLASSES' setting like below REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.TokenAuthentication', ), 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.IsAuthenticated', ) } Now you must run 'python manage.py migrate' after adding above settings to update the database with new Token model. You can create tokens for existing users like below from rest_framework.authtoken.models import Token token = Token.objects.create(user=) … -
Talk Python Podcast Interview - Teaching Django
An interview with Michael Kennedy on learning and teaching Django. -
Distillery Developer Is a Driving Force in Building Kodi’s Open Source Software
Think about the last time you were frustrated by a computer software problem. Now, imagine that you could simply elect to fix the problem yourself. Back in 2014, that’s exactly what happened to Distillery Full Stack Developer Anton Fedchin (afedchin). The post Distillery Developer Is a Driving Force in Building Kodi’s Open Source Software appeared first on Distillery. -
Is Django a Full Stack Framework?
Clearing up common confusion on front-end vs back-end. -
Django Tips & Tricks #11 - Finding High-impact Performance Bottlenecks
Introduction When optimizing performance of web application, a common mistake is to start with optimizing the slowest page(or API). In addition to considering response time, we should also consider the traffic it is receving to priorotize the order of optimization. In this article we will profile a django webapp, find high-impact performance bottlenecks and then start optimization them to yield better performance. Profiling django-silk is an open source profiling tool which intercepts and stores HTTP requests data. Install it with pip. pip install django-silk Add silk to installed apps and include silk middleware in django settings. MIDDLEWARE = [ ... 'silk.middleware.SilkyMiddleware', ... ] INSTALLED_APPS = ( ... 'silk' ) Run migrations so that Silk can create required database tables to store profile data. $ python manage.py makemigrations $ python manage.py migrate $ python manage.py collectstatic Include silk urls in root urlconf to view the profile data. urlpatterns += [url(r'^silk/', include('silk.urls', namespace='silk'))] On silk requests page(http://host/silk/requests/), we can see all requests and sort them by overall time or time spent in database. High Impact Bottlenecks Silk creates silk_request table which contains information about the requests processed by django. $ pgcli library> \d silk_request; +--------------------+--------------------------+-------------+ | Column | Type | Modifiers | … -
Find High-impact Performance Bottlenecks in Django
Introduction When optimizing performance of web application, a common mistake is to start with optimizing the slowest page(or API). In addition to considering response time, we should also consider the traffic it is receving to priorotize the order of optimization. In this article we will profile a django webapp, find high-impact performance bottlenecks and then start optimization them to yield better performance. Profiling django-silk is an open source profiling tool which intercepts and stores HTTP requests data. Install it with pip. pip install django-silk Add silk to installed apps and include silk middleware in django settings. MIDDLEWARE = [ ... 'silk.middleware.SilkyMiddleware', ... ] INSTALLED_APPS = ( ... 'silk' ) Run migrations so that Silk can create required database tables to store profile data. $ python manage.py makemigrations $ python manage.py migrate $ python manage.py collectstatic Include silk urls in root urlconf to view the profile data. urlpatterns += [url(r'^silk/', include('silk.urls', namespace='silk'))] On silk requests page(http://host/silk/requests/), we can see all requests and sort them by overall time or time spent in database. High Impact Bottlenecks Silk creates silk_request table which contains information about the requests processed by django. $ pgcli library> \d silk_request; +--------------------+--------------------------+-------------+ | Column | Type | Modifiers | … -
Django 'Hello, World' with Docker
How to start a new project with Django and Docker. -
Django Authentication — Login, Register, Logout and Password Reset
In this tutorial, you'll learn how to easily add a complete authentication system to your Django application with login, logout and password change and reset functionalities. We'll also be using django-crispy-forms and Bootstrap 4 for styling the application UI. Prerequisites Let's start with the prerequisites for this tutorial. In order to follow the tutorial step by step, you'll need a few requirements, such as: Basic knowledge of Python, Working knowledge of Django (django-admin.py and manage.py), A recent version of Python 3 installed on your system (the latest version is 3.7) We will be using pip and venv which are bundled as modules in recent versions of Python so you don't actually need to install them unless you are working with old versions. If you are ready, lets go started! Creating a Virtual Environment A virtual environment allows you to isolate your current project dependencies from the rest of packages installed globally on your system or in the other virtual environments. You can either use virtualenv which needs to be installed on your system or the venv module available as a module in recent versions of Python 3. Go to your command terminal and run: $ python -m venv env Next, … -
Understanding middleware functionality in django2.0
Middlewares are used to modify the request object which is sent to the view or to modify the response object returned from the view. They allow us to modify request/response globally. Django's old-style middleware: Prior to Django 1.10, there were 5 hooks. Any class that implements process_request(), process_view(), process_exception(), process_template_response() and process_response() methods can act as a middleware and all of these are specified in the setting MIDDLEWARE_CLASSES. The first two methods - process_request(), process_view() are executed before the execution of the view. The next three methods, process_exception(), process_template_response() and process_response() are executed after view returns the response object. Django's new-style middleware: The most important change you need to do when upgrading to Django 2.0 is to change MIDDLEWARE_CLASSES to MIDDLEWARE in settings.py file. In django 2.0 support for old-style middleware using settings.MIDDLEWARE_CLASSES is removed. The old middleware must be a class where as the new middleware is any callable, which takes a get_response callable and returns a callable that takes the request and returns a response. These middlewares should be specified in MIDDLEWARE setting. class TimeStampMiddleware(object): def __init__(self, get_response): self.get_response = get_response def __call__(self, request): request.timestamp = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S') response = self.get_response(request) return response Note: Here the get_response can … -
Django Form Example—Bootstrap 4 UI via django-crispy-forms
In this practical tutorial, you will build a simple example Django application with a form styled with Bootstrap 4. In this tutorial, you'll be using django-crispy-forms, a popular package that makes it easy for Django developers to create beautiful forms easily and without re-inventing the wheel. In this tutorial, you'll also be using Bootstrap 4—the latest version of the most popular CSS and HTML framework for building HTML interfaces—to style the form. The django-crispy-forms enables you to quickly add and render Bootstrap 4 styled forms with a few lines of code. Prerequisites You need to have these requirements if you want to create the example in this tutorial, step by step in your machine: A recent version of Python 3 (3.7 is the latest), A basic knowledge of Python, A working knowledge of Django. Creating a Virtual Environment & Installing Django First, begin by creating a virtual environment for your project using the venv module: $ python -m venv env Next, activate your environment using source: $ source env/bin/activate Next, install django in your virtual environment using pip: $ python -m pip install django Creating a Django Project & Application After installing Django, you need to create a project using …