In Django, One-to-Many relations are modeled by the ForeignKey
. Under
some circumstances, we may wish to collect some information (e.g. count,
min, max, avg, etc) from related objects. For example, in a blog
app, we may wish to build a table which lists the title and the number of …
Tag | python
-
-
Full-text Search with Django and PostgreSQL
Django has several PostgreSQL database functions to support full-text search. If you are using PostgreSQL as the database backend, then it is easy to add full-text search to your Django app.
In this post, I would like to build an demo app with full-text search. This post covers several PostgreSQL-specific …
-
Django ORM and Updating Counters
Counters are common in website development. Most websites collect the number of page views with counters. E-commerce websites keep track of the quantity of a commodity with counters. However, it is hard to implement a correct counter with Django ORM.
In this post, I would like to cover three ways …
-
Python Property Decorator
-
Flask and Socket.IO
Under some scenarios, we would like to push a message from an HTTP server to clients. For example, in a group messaging application, whenever a user sends a message to the server, the server has to push such message to everyone. Since 2001, several techniques have been proposed. Eventually, WebSocket …
-
Python New Style Class
Recently, I am curious about this code snippet:
class Test(object): def __init__(): pass
Why do we have to extend or inherit from
object
type?There are no differences with or without
(object)
in Python 3. But there are significant differences in Python 2. If a class inherits (either directly … -
Comparison and Sorting in Python3
Although I have written Python for several years, I am still not very familiar with its idioms. In particular, I don't quite understand how to compare and sort the objects in Python. That's the reason why I am writing this article.
The rest of this article consists of following sections …
-
Waliki Installation
Waliki is a simple wiki app for Django. We can write wiki contents with reStructuredText and the contents will be stored in a Git repository. In this post, I would like to introduce the instructions to install Waliki.
Getting Started
First, install the related Ubuntu packages:
$ sudo apt-get install git …
-
Python Package Manager: PIP
The Python package manager pip is a tool to manage the installed site packages. With pip, we don't have to be worried about the package dependencies anymore. pip will download the required packages from Python Package Index automatically.
Install Packages
To download and install the packages from Python Package Index …