<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>Python on Shaowen Chen's Website</title><link>https://www.chenshaowen.com/en/tags/python/</link><description>Recent content in Python on Shaowen Chen's Website</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>&amp;copy;2016 - {year}, All Rights Reserved.</copyright><lastBuildDate>Thu, 28 Mar 2024 00:00:00 +0000</lastBuildDate><sy:updatePeriod>weekly</sy:updatePeriod><atom:link href="https://www.chenshaowen.com/en/tags/python/atom.xml" rel="self" type="application/rss+xml"/><item><title>Conda Installation and Use</title><link>https://www.chenshaowen.com/en/blog/conda-install-and-use.html</link><pubDate>Thu, 28 Mar 2024 00:00:00 +0000</pubDate><atom:modified>Thu, 28 Mar 2024 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/conda-install-and-use.html</guid><description>1. Installing conda 1 2 3 wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh bash Miniconda3-latest-Linux-x86_64.sh rm -rf Miniconda3-latest-Linux-x86_64.sh However, Miniconda cannot be used for free at large-scale commercial deployments, so you can use Miniforge as a drop-in alternative.
1 2 wget &amp;#34;https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh&amp;#34; bash Miniforge3-$(uname)-$(uname -m).sh 2. Changing the default configuration 2.1 Initializing the Shell Without initialization, activating an environment reports CondaError: Run 'conda init' before 'conda activate'.</description><dc:creator>微信公众号</dc:creator><category>Conda</category><category>Python</category><category>AI</category><category>Environment</category><category>Operations</category></item><item><title>Usage of the transformers Library</title><link>https://www.chenshaowen.com/en/blog/usage-of-transformers-lib.html</link><pubDate>Tue, 22 Aug 2023 00:00:00 +0000</pubDate><atom:modified>Tue, 22 Aug 2023 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/usage-of-transformers-lib.html</guid><description>transformers is a Python library developed by Hugging Face for using and training pretrained Transformer models in natural language processing (NLP) tasks. It provides many powerful tools and features that make working with text data and building NLP models much easier. The library is widely used across a variety of</description><dc:creator>微信公众号</dc:creator><category>Transformer</category><category>AI</category><category>LLM</category><category>NLP</category><category>Python</category></item><item><title>What Is Functional Programming</title><link>https://www.chenshaowen.com/en/blog/what-is-functional-programming.html</link><pubDate>Wed, 02 Sep 2020 00:00:00 +0000</pubDate><atom:modified>Wed, 02 Sep 2020 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/what-is-functional-programming.html</guid><description>1. What a Programming Paradigm Is A programming paradigm is a class of typical programming conventions. On one hand, it provides engineers with a way to model entities, linking the physical world to code; on the other hand, it provides engineers with a way of thinking about code and programs.</description><dc:creator>微信公众号</dc:creator><category>Functional Programming</category><category>Go</category><category>Programming Paradigm</category><category>Python</category><category>What Is</category></item><item><title>Django Performance: Database Query Optimization</title><link>https://www.chenshaowen.com/en/blog/database-query-optimization-of-django-performance.html</link><pubDate>Wed, 20 Mar 2019 00:00:00 +0000</pubDate><atom:modified>Wed, 20 Mar 2019 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/database-query-optimization-of-django-performance.html</guid><description>This article mainly offers optimization advice on Django fields and queries, and also introduces a performance analysis tool called Django-silk. I hope it helps you develop high-performance Django projects.
1. DBA&amp;rsquo;s Advice 1.1 Table Field Design Avoid null values; null values are hard to optimize queries around and take up extra index space Prefer INT over BIGINT, and describe fields as accurately as possible Use enums or integers instead of string types Use TIMESTAMP instead of DATETIME Do not put more than 20 fields in a single table Store IPs as integers 1.</description><dc:creator>微信公众号</dc:creator><category>Database</category><category>Optimization</category><category>Performance</category><category>Django</category><category>Python</category><category>R&amp;D</category></item><item><title>Advanced Pytest: Mock</title><link>https://www.chenshaowen.com/en/blog/mock-of-pytest.html</link><pubDate>Sun, 27 Jan 2019 00:00:00 +0000</pubDate><atom:modified>Sun, 27 Jan 2019 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/mock-of-pytest.html</guid><description>1. Why We Need Mock When writing unit tests, the function under test is sometimes not a self-contained executable unit. It depends on external resources, such as the return value of another function or a value in a row of a database. To shield the test from interference from external</description><dc:creator>微信公众号</dc:creator><category>Testing</category><category>Python</category><category>Pytest</category><category>Learning</category></item><item><title>Getting Started with Pytest</title><link>https://www.chenshaowen.com/en/blog/101-of-pytest.html</link><pubDate>Sat, 29 Dec 2018 00:00:00 +0000</pubDate><atom:modified>Sat, 29 Dec 2018 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/101-of-pytest.html</guid><description>The Pytest framework is simple to use, rich in plugins, and powerful, and it is widely used for Python automated testing. This article introduces some basic concepts and usage of Pytest. 1. How It Runs Step one, Pytest reads its configuration from the command line or a file. Step two,</description><dc:creator>微信公众号</dc:creator><category>Testing</category><category>Python</category><category>Pytest</category><category>R&amp;D</category><category>Learning</category><category>Automated Testing</category><category>Unit Testing</category><category>Best Practices</category></item><item><title>API of Serializer and ViewSet in restframework</title><link>https://www.chenshaowen.com/en/blog/api-of-viewset-and-serializer-in-rest-framework.html</link><pubDate>Tue, 20 Nov 2018 00:00:00 +0000</pubDate><atom:modified>Tue, 20 Nov 2018 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/api-of-viewset-and-serializer-in-rest-framework.html</guid><description>1. Serializer 1.1 Data Validation When deserializing data, the validity of the data needs to be checked. At this point you can call is_valid() for validation, and if a validation error occurs, you can get the error message from the .errors attribute. For example:
1 2 3 4 serializer.is_valid() # False serializer.</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>API</category><category>Interface</category><category>R&amp;D</category></item><item><title>ViewSet and Serializer in restframework</title><link>https://www.chenshaowen.com/en/blog/viewset-and-serializer-in-rest-framework.html</link><pubDate>Sun, 18 Nov 2018 00:00:00 +0000</pubDate><atom:modified>Sun, 18 Nov 2018 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/viewset-and-serializer-in-rest-framework.html</guid><description>1. View Class in Django First, recall how Django handles a request. After receiving a request, Django creates a handler of type WSGIHandler, and the handler controls the entire processing flow.
So how are the request URL and the View associated with each other?
Django first loads the URLconf according to the ROOT_URLCONF setting, then matches the URLpatterns in the URLconf one by one in order, stopping as soon as a match is found.</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>API</category><category>Framework</category><category>Interface</category><category>R&amp;D</category></item><item><title>Django Full-Stack Optimization Guide</title><link>https://www.chenshaowen.com/en/blog/django-full-stack-optimization-guide.html</link><pubDate>Thu, 15 Nov 2018 00:00:00 +0000</pubDate><atom:modified>Thu, 15 Nov 2018 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/django-full-stack-optimization-guide.html</guid><description>As the data volume exploded, the system responded very slowly. We carried out a series of optimizations on the application, and the system&amp;rsquo;s response time improved by an order of magnitude. Overall, optimizations in file compression and faster network access gave a noticeable boost to frontend performance, while optimizations in stored procedures, caching, and logic code gave a noticeable boost to backend performance.</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>Optimization</category><category>Frontend</category><category>Backend</category><category>Guide</category><category>R&amp;D</category></item><item><title>Troubleshooting and Resolving Celery Failures on Large Files</title><link>https://www.chenshaowen.com/en/blog/solving-the-problem-of-celery-processe-large-file-failure.html</link><pubDate>Wed, 24 Oct 2018 00:00:00 +0000</pubDate><atom:modified>Wed, 24 Oct 2018 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/solving-the-problem-of-celery-processe-large-file-failure.html</guid><description>1. A Small Requirement We run into small requirements all the time, but they are not always simple to implement. Here is a simple file upload requirement, broken into the following steps: The user uploads a large file on the page The large file is temporarily stored in the internal</description><dc:creator>微信公众号</dc:creator><category>Celery</category><category>Python</category><category>Django</category><category>Failure</category><category>Troubleshooting</category><category>Large Files</category><category>R&amp;D</category></item><item><title>Git and Development Environment Setup</title><link>https://www.chenshaowen.com/en/blog/git-and-development-environment-setup.html</link><pubDate>Fri, 19 Oct 2018 00:00:00 +0000</pubDate><atom:modified>Fri, 19 Oct 2018 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/git-and-development-environment-setup.html</guid><description>Compiled from the &amp;ldquo;Development Tips&amp;rdquo; series, gathering practices around Git collaboration and development environment setup. 1. warning: LF will be replaced by CRLF Windows, Linux, and Mac are inconsistent in how they mark line endings in files. Windows uses CRLF as the terminator, while Linux and Mac use LF. Git</description><dc:creator>微信公众号</dc:creator><category>Git</category><category>Python</category><category>Windows</category><category>R&amp;D</category><category>Environment</category></item><item><title>Python and Django Development Practices</title><link>https://www.chenshaowen.com/en/blog/python-and-django-development-practices.html</link><pubDate>Fri, 19 Oct 2018 00:00:00 +0000</pubDate><atom:modified>Fri, 19 Oct 2018 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/python-and-django-development-practices.html</guid><description>Compiled from the &amp;ldquo;Development Tips&amp;rdquo; series, collecting common problems and solutions in Python and Django development. 1. Sorting Python Iterables Iterable objects fall into 3 main categories: All sequence types, such as list, str, and tuple Some non-sequence types, such as dict and file Objects that contain an __iter__() or</description><dc:creator>微信公众号</dc:creator><category>Python</category><category>Django</category><category>R&amp;D</category><category>Learning</category><category>Backend</category></item><item><title>How to Decouple Modules with Django Signal</title><link>https://www.chenshaowen.com/en/blog/how-to-use-django-signal-decoupling-module.html</link><pubDate>Fri, 12 Oct 2018 00:00:00 +0000</pubDate><atom:modified>Fri, 12 Oct 2018 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/how-to-use-django-signal-decoupling-module.html</guid><description>Recently I was responsible for developing a backend-heavy application. The data flow in this application is complex, and the processing logic has piled up in a redundant mess. The project&amp;rsquo;s tech stack is Django + Vuejs. The frontend is bundled with Webpack, managed in modules, and mainly displays data. The backend involves many modules, many processing rules, and many data tables, so every time I had to modify an earlier feature I spent a lot of time reviewing the code.</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>Design</category><category>Decoupling</category><category>R&amp;D</category></item><item><title>How to Package a Robot Framework Docker Image</title><link>https://www.chenshaowen.com/en/blog/how-to-package-a-docker-image-of-robot-framework.html</link><pubDate>Tue, 18 Sep 2018 00:00:00 +0000</pubDate><atom:modified>Tue, 18 Sep 2018 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/how-to-package-a-docker-image-of-robot-framework.html</guid><description>To make it easier for CI to integrate UI automation tests, the Robot Framework runtime needs to be packaged as a Docker image. This post covers the configuration and scripts involved in the packaging process. 1. Packaging Directory Structure 1 2 3 4 5 6 tree . ├──</description><dc:creator>微信公众号</dc:creator><category>Docker</category><category>RobotFramework</category><category>Python</category><category>Testing</category><category>CICD</category><category>Operations</category></item><item><title>Robot Framework Advanced (2)</title><link>https://www.chenshaowen.com/en/blog/senior-of-robot-framework-2.html</link><pubDate>Thu, 16 Aug 2018 00:00:00 +0000</pubDate><atom:modified>Thu, 16 Aug 2018 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/senior-of-robot-framework-2.html</guid><description>Settings Table The settings table in Robot Framework mainly serves two purposes. For a detailed explanation, see here. Import test, resource, and variable files. Define metadata. In the Setting table: 1 2 3 4 5 Library 引入库 Resource 引入资源文件 Variables 引入变</description><dc:creator>微信公众号</dc:creator><category>RobotFramework</category><category>Python</category><category>Testing</category><category>Automation</category><category>DevOps</category></item><item><title>Robot Framework Advanced (1)</title><link>https://www.chenshaowen.com/en/blog/senior-of-robot-framework-1.html</link><pubDate>Wed, 15 Aug 2018 00:00:00 +0000</pubDate><atom:modified>Wed, 15 Aug 2018 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/senior-of-robot-framework-1.html</guid><description>pybot Command Run all test cases 1 pybot . Run a certain test suite 1 pybot testsuite.txt Run a test case in a certain test suite 1 pybot --test case_name testsuit.txt Output the test results to a fixed path 1 pybot --ouputdir your_ouput_dir testsuit.txt Run test cases that contain a</description><dc:creator>微信公众号</dc:creator><category>RobotFramework</category><category>Python</category><category>Testing</category><category>Automation</category><category>DevOps</category></item><item><title>How to Create GitLab Labels Automatically with python-gitlab</title><link>https://www.chenshaowen.com/en/blog/how-to-create-gitlab-label-using-python-gitlab.html</link><pubDate>Sun, 05 Aug 2018 10:00:00 +0000</pubDate><atom:modified>Sun, 05 Aug 2018 10:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/how-to-create-gitlab-label-using-python-gitlab.html</guid><description>Using GitLab issues for project management is a very Dev-friendly thing. Entering issues, opening Merge Requests, creating milestones — these all advance dynamically during development. But creating a pile of Labels for every new project is a headache. This article is mainly about solving that problem. 1. GitLab Label Before</description><dc:creator>微信公众号</dc:creator><category>GitLab</category><category>Python</category><category>Project Management</category><category>DevOps</category><category>R&amp;D</category></item><item><title>Robot Framework Basics</title><link>https://www.chenshaowen.com/en/blog/basic-of-robot-framework.html</link><pubDate>Tue, 24 Jul 2018 00:00:00 +0000</pubDate><atom:modified>Tue, 24 Jul 2018 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/basic-of-robot-framework.html</guid><description>This post mainly introduces some basic concepts of Robot Framework and how to write a test case. 1. Basic Elements 1.1 Keywords Robot Framework keywords are similar to functions. They are divided into system keywords and user-defined keywords. System keywords, imported by loading a Library User keywords, imported by loading</description><dc:creator>微信公众号</dc:creator><category>Python</category><category>Testing</category><category>RobotFramework</category><category>DevOps</category><category>Learning</category><category>Automated Testing</category><category>R&amp;D</category><category>CICD</category></item><item><title>How to Safely Access request from Anywhere in Django</title><link>https://www.chenshaowen.com/en/blog/how-to-secure-get-request-in-django.html</link><pubDate>Tue, 26 Jun 2018 00:00:00 +0000</pubDate><atom:modified>Tue, 26 Jun 2018 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/how-to-secure-get-request-in-django.html</guid><description>In Django, request holds all the information for a single request. Backend processing logic frequently needs information from request. For example, the DRF framework may want to be able to obtain request at any time, or pass some parameters globally. There are third-party Django apps with tools that can satisfy</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>R&amp;D</category><category>Tips</category><category>Learning</category><category>DRF</category><category>Thread Safety</category></item><item><title>Python2 Source Code Study: Dictionary and List Implementation</title><link>https://www.chenshaowen.com/en/blog/dictionary-and-list-structure-in-python2.html</link><pubDate>Mon, 12 Mar 2018 11:22:55 +0000</pubDate><atom:modified>Mon, 12 Mar 2018 11:22:55 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/dictionary-and-list-structure-in-python2.html</guid><description>1. Why Dictionary Lookups Are Faster Than List Lookups First, take a look at the following piece of code. 1 2 3 4 5 6 7 8 9 10 11 12 13 from time import time t = time() data = [chr(i) for i in range(97, 123)] # data =</description><dc:creator>微信公众号</dc:creator><category>Python</category><category>Source Code</category><category>Learning</category><category>R&amp;D</category></item><item><title>Python2 Source Code Study: pyc</title><link>https://www.chenshaowen.com/en/blog/python2-source-of-pyc.html</link><pubDate>Fri, 09 Mar 2018 00:00:00 +0000</pubDate><atom:modified>Fri, 09 Mar 2018 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/python2-source-of-pyc.html</guid><description>This article uses the Python 2.7.8 source code as an example.
1. Common File Formats in Python py file A Python source code file, which can be modified with a text editor.
pyc file The bytecode file generated after Python source code is compiled.
pyw file When a pyc file is executed, a console window appears; when a pyw file is executed, it does not.</description><dc:creator>微信公众号</dc:creator><category>Python</category><category>Source Code</category><category>Compilation</category><category>Learning</category><category>R&amp;D</category></item><item><title>How to Build a PyPI Server with devpi</title><link>https://www.chenshaowen.com/en/blog/how-to-build-a-pypi-server-using-devpi.html</link><pubDate>Sun, 04 Mar 2018 00:00:00 +0000</pubDate><atom:modified>Sun, 04 Mar 2018 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/how-to-build-a-pypi-server-using-devpi.html</guid><description>When you install Python packages with pip, it looks up the corresponding package on the https://pypi.python.org/simple/ index by default, then downloads and installs it. But in an intranet environment, or when you need to publish some private packages to designated users, you have to build your own PyPI Server. This post mainly records the process of building a PyPI Server index with the devpi tool, along with some commonly used commands.</description><dc:creator>微信公众号</dc:creator><category>Python</category><category>devpi</category><category>Tools</category><category>Operations</category><category>Learning</category><category>PyPI</category><category>Private Index</category><category>Package Management</category><category>Intranet</category></item><item><title>Django Model and E-R Diagram</title><link>https://www.chenshaowen.com/en/blog/django-model-and-er-diagram.html</link><pubDate>Fri, 02 Mar 2018 00:00:00 +0000</pubDate><atom:modified>Fri, 02 Mar 2018 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/django-model-and-er-diagram.html</guid><description>As requirements are gradually confirmed, the system&amp;rsquo;s DB model is gradually confirmed as well. Sometimes you use a tool like MySQL Workbench to draw an E-R diagram and then generate MySQL database tables, and at that point you need to reverse-generate Django Models; other times you write the Django Models directly, but then you need to look at the E-R diagram.</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>Database</category><category>Design</category><category>Model</category><category>R&amp;D</category></item><item><title>Django Development Conventions (Part 1)</title><link>https://www.chenshaowen.com/en/blog/development-specification-1-of-django.html</link><pubDate>Sat, 27 Jan 2018 00:00:00 +0000</pubDate><atom:modified>Sat, 27 Jan 2018 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/development-specification-1-of-django.html</guid><description>This article mainly lays out a few things to watch out for during Django development. A consistent coding style and sound design principles help a project&amp;rsquo;s development and maintenance, and are worth developers studying and discussing continuously. 1. Encoding Declaration When the Python interpreter executes code, it needs to be</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>Conventions</category><category>R&amp;D</category><category>Learning</category><category>Best Practices</category><category>Code Style</category><category>Architecture</category></item><item><title>Processes, Threads, and Coroutines in Python</title><link>https://www.chenshaowen.com/en/blog/process-and-thread-in-python.html</link><pubDate>Sat, 06 Jan 2018 11:22:55 +0000</pubDate><atom:modified>Sat, 06 Jan 2018 11:22:55 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/process-and-thread-in-python.html</guid><description>1. Processes A process is an instance of a running program, and it is the most basic unit by which the kernel allocates resources. A process has its own independent heap and stack, its own address space, and its own resource handles. Processes are scheduled by the OS, the scheduling</description><dc:creator>微信公众号</dc:creator><category>Python</category><category>Concurrency</category><category>Processes</category><category>Threads</category><category>Coroutines</category><category>R&amp;D</category><category>Learning</category></item><item><title>Python's Class Function Methods</title><link>https://www.chenshaowen.com/en/blog/class-function-method-of-python.html</link><pubDate>Fri, 29 Dec 2017 00:00:00 +0000</pubDate><atom:modified>Fri, 29 Dec 2017 00:00:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/class-function-method-of-python.html</guid><description>1. Function Methods A function is an organized, reusable snippet of code used to implement a single or related piece of functionality. Functions improve an application&amp;rsquo;s modularity and the reuse rate of code. Python provides many built-in functions, such as print() and str(). At the same time, Python also allows</description><dc:creator>微信公众号</dc:creator><category>Python</category><category>Conventions</category><category>Functions</category><category>R&amp;D</category></item><item><title>Interactive Notebook - Jupyter</title><link>https://www.chenshaowen.com/en/blog/interactive-notebook-jupyter.html</link><pubDate>Mon, 25 Dec 2017 17:22:45 +0000</pubDate><atom:modified>Mon, 25 Dec 2017 17:22:45 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/interactive-notebook-jupyter.html</guid><description>1. Introduction Jupyter Notebook (formerly IPython notebook) is an interactive notebook that supports running more than 40 programming languages. Jupyter Notebook is in fact a web application that lets you create and share program documents, with support for live code, mathematical equations, visualizations, and Markdown. Its uses include data cleaning</description><dc:creator>微信公众号</dc:creator><category>Tools</category><category>Python</category><category>Notes</category><category>Jupyter</category><category>Learning</category><category>R&amp;D</category><category>Data Analysis</category><category>Machine Learning</category><category>Visualization</category></item><item><title>RabbitMQ Message Queue</title><link>https://www.chenshaowen.com/en/blog/message-queue-about-rabbitmq.html</link><pubDate>Sat, 23 Dec 2017 20:51:22 +0000</pubDate><atom:modified>Sat, 23 Dec 2017 20:51:22 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/message-queue-about-rabbitmq.html</guid><description>1. Where a Message Queue Fits 1.1 Asynchronous Processing Use case: after a user registers, a registration email and a registration SMS must be sent. With the synchronous approach, system performance (concurrency, throughput, response time) hits a bottleneck. 1.2 Application Decoupling Use case: after a user places an order, the</description><dc:creator>微信公众号</dc:creator><category>RabbitMQ</category><category>Middleware</category><category>Celery</category><category>Python</category><category>Message</category><category>Queue</category></item><item><title>Error Code Design and Unified Exception Handling in Django</title><link>https://www.chenshaowen.com/en/blog/error-code-design-and-unified-processing-in-django.html</link><pubDate>Mon, 30 Oct 2017 21:50:33 +0000</pubDate><atom:modified>Mon, 30 Oct 2017 21:50:33 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/error-code-design-and-unified-processing-in-django.html</guid><description>I currently use Django for SaaS development, and I develop and maintain several SaaS applications at the same time. Many SaaS applications have agreed-upon error codes, some used to handle login state, others to mark business logic status. For a feature that is so strongly shared across projects, it is</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>Error Codes</category><category>Middleware</category><category>R&amp;D</category><category>Learning</category><category>API</category><category>Best Practices</category></item><item><title>How to Learn a New Programming Language: Taking Python as an Example</title><link>https://www.chenshaowen.com/en/blog/how-to-learn-a-new-programming-language-taking-python-as-an-example.html</link><pubDate>Fri, 13 Oct 2017 23:00:06 +0000</pubDate><atom:modified>Fri, 13 Oct 2017 23:00:06 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/how-to-learn-a-new-programming-language-taking-python-as-an-example.html</guid><description>1. Understand the Background of the New Language ABC was a teaching language designed specifically for non-professional programmers, but because it was closed, it did not succeed. During Christmas 1989, Guido van Rossum developed a new script interpreter and named it Python, as a kind of successor to the ABC</description><dc:creator>微信公众号</dc:creator><category>Python</category><category>Learning</category><category>Programming</category><category>R&amp;D</category></item><item><title>Building a Django Development Environment with Vagrant</title><link>https://www.chenshaowen.com/en/blog/build-django-development-environment-using-vagrant.html</link><pubDate>Mon, 25 Sep 2017 21:56:05 +0000</pubDate><atom:modified>Mon, 25 Sep 2017 21:56:05 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/build-django-development-environment-using-vagrant.html</guid><description>Docker solves the problem of environment isolation on the same machine and improves the efficiency of operations and deployment. Vagrant gives developers a unified, near-fully-isolated environment for development and testing. This article mainly discusses how to build a Django development environment with Vagrant. Versions: VirtualBox 5.0, Vagrant 1.8. 1. Basic</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>Vagrant</category><category>Tools</category><category>Development</category><category>R&amp;D</category><category>Operations</category></item><item><title>Building a Django Development Environment with Docker from Scratch (6) uWSGI, Django</title><link>https://www.chenshaowen.com/en/blog/how-to-package-django-development-environments-using-docker-6.html</link><pubDate>Sun, 24 Sep 2017 18:03:22 +0000</pubDate><atom:modified>Sun, 24 Sep 2017 18:03:22 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/how-to-package-django-development-environments-using-docker-6.html</guid><description>1. Directory Structure The django-devops-uwsgi directory holds the image build files that package uWSGI and Django. It installs the necessary packages such as uWSGI, pip, and virtualenv into the image.
When a container is created from the image, the start.sh script runs: it creates the Python virtual runtime environment, installs the dependency packages from Django&amp;rsquo;s requirements.</description><dc:creator>微信公众号</dc:creator><category>Docker</category><category>Django</category><category>Python</category><category>Services</category><category>Tools</category><category>R&amp;D</category><category>Operations</category></item><item><title>Packaging a Django Development Environment with Docker from Scratch (5) Nginx</title><link>https://www.chenshaowen.com/en/blog/how-to-package-django-development-environments-using-docker-5.html</link><pubDate>Sun, 24 Sep 2017 14:34:35 +0000</pubDate><atom:modified>Sun, 24 Sep 2017 14:34:35 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/how-to-package-django-development-environments-using-docker-5.html</guid><description>1. Directory Structure 1 2 3 4 5 6 7 8 9 10 11 12 ├── django-devops-nginx │ ├── Dockerfile │ └── nginx.repo ├── django-devops-compose │ ├── docker-compose.yml │ ├── www │ ├── conf │ │ ├── nginx.conf │ ├── log │ │ ├── nginx │ │ │ ├── access.log │ │ │ ├── error.</description><dc:creator>微信公众号</dc:creator><category>Docker</category><category>Services</category><category>Tools</category><category>Django</category><category>Nginx</category><category>Python</category><category>R&amp;D</category><category>Operations</category></item><item><title>Packaging a Django Development Environment with Docker from Scratch (3) Docker Compose</title><link>https://www.chenshaowen.com/en/blog/how-to-package-django-development-environments-using-docker-3.html</link><pubDate>Sat, 23 Sep 2017 19:56:03 +0000</pubDate><atom:modified>Sat, 23 Sep 2017 19:56:03 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/how-to-package-django-development-environments-using-docker-3.html</guid><description>1. Basic Concepts Docker Compose is a Docker tool for defining and running complex applications. With Docker Compose, you can define a multi-container application in a single file, then use a single command to start your application and finish all the preparation work.
Docker Compose positions itself as &amp;lsquo;defining and running complex applications with Docker&amp;rsquo;.</description><dc:creator>微信公众号</dc:creator><category>Docker</category><category>Services</category><category>Tools</category><category>Django</category><category>Python</category><category>R&amp;D</category><category>Operations</category></item><item><title>Packaging a Django Development Environment with Docker from Scratch (2) Dockerfile</title><link>https://www.chenshaowen.com/en/blog/how-to-package-django-development-environments-using-docker-2.html</link><pubDate>Fri, 22 Sep 2017 19:52:27 +0000</pubDate><atom:modified>Fri, 22 Sep 2017 19:52:27 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/how-to-package-django-development-environments-using-docker-2.html</guid><description>1. Basic Concepts A Dockerfile is a collection of instructions for building a Docker image. Docker reads Dockerfile instructions to build an image automatically. A Dockerfile is similar to a Makefile: both are text files that organize all the instructions in the order the image is built.
The command to build a Docker image:</description><dc:creator>微信公众号</dc:creator><category>Docker</category><category>Django</category><category>Python</category><category>Services</category><category>Tools</category><category>R&amp;D</category><category>Operations</category></item><item><title>Atom as a Lightweight Python Full-Stack IDE</title><link>https://www.chenshaowen.com/en/blog/atom-create-lightweight-python-full-stack-ide.html</link><pubDate>Sun, 06 Aug 2017 14:51:16 +0000</pubDate><atom:modified>Sun, 06 Aug 2017 14:51:16 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/atom-create-lightweight-python-full-stack-ide.html</guid><description>At the moment I use PyCharm as my integrated development tool for both front end and back end. My main stack is JavaScript, CSS, ECMAScript 6, Vue, Python, Django, Mako, and Markdown. Front-end work has been growing steadily lately, and PyCharm seems to be struggling. Atom, Sublime Text, and Visual Studio Code became the candidates; Atom is maintained by GitHub, has better community support, and is more configurable and more fun to play with.</description><dc:creator>微信公众号</dc:creator><category>Tools</category><category>Python</category><category>R&amp;D</category><category>IDE</category><category>Atom</category><category>Full-Stack</category></item><item><title>Django Forms Functionality</title><link>https://www.chenshaowen.com/en/blog/django-forms-function.html</link><pubDate>Fri, 21 Jul 2017 21:29:40 +0000</pubDate><atom:modified>Fri, 21 Jul 2017 21:29:40 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/django-forms-function.html</guid><description>1. Automatically Generating HTML Form Elements A Widget is the tool used to render an HTML element. Specifying a widget 1 2 3 4 5 6 from django import forms class CommentForm(forms.Form): name = forms.CharField() url = forms.URLField() comment = forms.CharField(widget=forms.Textarea) Output of CommentForm().as_table() 1 2 3 4 5 6</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>Security</category><category>R&amp;D</category></item><item><title>Django ORM and SQL</title><link>https://www.chenshaowen.com/en/blog/sql-code-about-django-orm.html</link><pubDate>Fri, 21 Jul 2017 13:21:08 +0000</pubDate><atom:modified>Fri, 21 Jul 2017 13:21:08 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/sql-code-about-django-orm.html</guid><description>1. Basic Concepts ORM: Object Relational Mapping. Its job is to map between a relational database and objects. No complex SQL statements are needed — operating on data is as simple as operating on objects. QuerySet: the list of objects for a given model. A QuerySet lets you read data</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>Data</category><category>SQL</category><category>R&amp;D</category></item><item><title>Haystack Full-Text Search</title><link>https://www.chenshaowen.com/en/blog/haystack-full-text-search.html</link><pubDate>Fri, 21 Jul 2017 13:00:03 +0000</pubDate><atom:modified>Fri, 21 Jul 2017 13:00:03 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/haystack-full-text-search.html</guid><description>A quick word on the project requirements: the team needed to publish documentation externally. The documents are written in Markdown and need to be published as HTML. At first we used an Nginx + Jekyll solution. As the documentation grew, the document system developed a strong need for search. I</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>Data</category><category>Design</category><category>Search</category><category>R&amp;D</category></item><item><title>Django Signals</title><link>https://www.chenshaowen.com/en/blog/signal-of-django.html</link><pubDate>Thu, 13 Jul 2017 13:06:10 +0000</pubDate><atom:modified>Thu, 13 Jul 2017 13:06:10 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/signal-of-django.html</guid><description>1. Basic Concepts Django ships with a signal dispatcher built in. Signals help decouple program modules. When an event occurs elsewhere in the application, a designated function is notified. Signals let certain senders notify a group of receivers that some action has taken place. 2. Using Signals 2.1 Declaring a</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Backend</category><category>Python</category><category>R&amp;D</category><category>Learning</category><category>Decoupling</category><category>Events</category></item><item><title>Django Class-Based Views</title><link>https://www.chenshaowen.com/en/blog/class-based-view-of-django.html</link><pubDate>Tue, 11 Jul 2017 16:36:56 +0000</pubDate><atom:modified>Tue, 11 Jul 2017 16:36:56 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/class-based-view-of-django.html</guid><description>Django has two kinds of views: function-based views and class-based views. The role of a view is mainly to fill in logic and return a response body. Function-based views are hard to extend and have a low rate of code reuse. Class-based views, on the other hand, can use inheritance</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Backend</category><category>Python</category><category>Class-Based Views</category><category>R&amp;D</category></item><item><title>Permission Management in Django REST Framework</title><link>https://www.chenshaowen.com/en/blog/permissions-of-django-rest-framework.html</link><pubDate>Fri, 07 Jul 2017 06:47:19 +0000</pubDate><atom:modified>Fri, 07 Jul 2017 06:47:19 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/permissions-of-django-rest-framework.html</guid><description>1. Permission Management in DRF Permission management in Django REST Framework consists of two parts.
One is Authentication. It specifies how the user is authenticated, obtaining request.user. The other is Permissions. It performs permission control over Django resources and user categories. 1.1 Authentication Methods The relevant source is in the rest_framework/authentication.</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>Backend</category><category>Security</category><category>API</category><category>Permissions</category><category>R&amp;D</category></item><item><title>Django Template Inheritance</title><link>https://www.chenshaowen.com/en/blog/django-template-inherit.html</link><pubDate>Mon, 03 Jul 2017 19:17:11 +0000</pubDate><atom:modified>Mon, 03 Jul 2017 19:17:11 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/django-template-inherit.html</guid><description>1. The Scenario In a project, elements such as the header and footer are often reused. To avoid rewriting these elements on every page, and so that a change does not require editing each page individually, the common parts need to be extracted — that is Django template inheritance. 2.</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>Templates</category><category>R&amp;D</category></item><item><title>Django Decorators</title><link>https://www.chenshaowen.com/en/blog/django-decorator.html</link><pubDate>Thu, 22 Jun 2017 23:55:59 +0000</pubDate><atom:modified>Thu, 22 Jun 2017 23:55:59 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/django-decorator.html</guid><description>When developing with a separated front end and back end, some of the API endpoints provided to the front end use GET requests and some use POST requests. To keep the back end from throwing an error while reading values from request in views.py, you had to check the request</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Demo</category><category>Decorators</category><category>Python</category></item><item><title>Django Snippets</title><link>https://www.chenshaowen.com/en/blog/snippets-of-django.html</link><pubDate>Thu, 22 Jun 2017 23:52:06 +0000</pubDate><atom:modified>Thu, 22 Jun 2017 23:52:06 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/snippets-of-django.html</guid><description>1. Auto-Register All Models in Admin admin.py
1 2 3 4 5 6 7 8 9 10 # -*- coding: utf-8 -*- import inspect from django.contrib import admin from . import models for name, obj in inspect.getmembers(models): try: if inspect.isclass(obj): admin.site.register(getattr(models, name)) except Exception as e: pass 2. Get All View Names Get all view names of the project</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>R&amp;D</category><category>Learning</category><category>Tips</category></item><item><title>Getting Started with Django REST Framework</title><link>https://www.chenshaowen.com/en/blog/101-of-django-rest-framework.html</link><pubDate>Thu, 22 Jun 2017 23:50:15 +0000</pubDate><atom:modified>Thu, 22 Jun 2017 23:50:15 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/101-of-django-rest-framework.html</guid><description>In the SaaS development I work on, there is a fairly high demand for development efficiency. From project initiation, prototype design and evaluation, requirements confirmation, frontend design, and backend development through to final acceptance, we complete one iteration in just a few weeks. Guided by agile development, we began rolling</description><dc:creator>微信公众号</dc:creator><category>Data</category><category>Backend</category><category>Interface</category><category>Django</category><category>Python</category><category>API</category><category>R&amp;D</category></item><item><title>Django Restful APIs with Tastypie</title><link>https://www.chenshaowen.com/en/blog/restful-api-of-using-django-tastypie.html</link><pubDate>Tue, 13 Jun 2017 21:31:13 +0000</pubDate><atom:modified>Tue, 13 Jun 2017 21:31:13 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/restful-api-of-using-django-tastypie.html</guid><description>1. Restful REST is short for Representational State Transfer, meaning &amp;ldquo;representation state transfer&amp;rdquo;. Restful is a development philosophy and a software architecture style for the World Wide Web. 1.1 Features of Restful Abstract resources Images, text, songs, and videos are all resource entities; on the network they are abstracted as</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>Interface</category><category>API</category><category>Tastypie</category><category>R&amp;D</category></item><item><title>The manage Command in Django</title><link>https://www.chenshaowen.com/en/blog/manage-command-in-django.html</link><pubDate>Mon, 15 May 2017 21:14:48 +0000</pubDate><atom:modified>Mon, 15 May 2017 21:14:48 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/manage-command-in-django.html</guid><description>Every Django project automatically generates a manage.py file. manage.py is a simple wrapper around django-admin; its job is to put the Django Project into the sys.path directory and set the DJANGO_SETTINGS_MODULE environment variable to the current Project&amp;rsquo;s settings.py file. In other words, the difference between django-admin and manage is that</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>Tools</category><category>Command</category><category>R&amp;D</category></item><item><title>Building a Reusable Django App</title><link>https://www.chenshaowen.com/en/blog/how-to-build-reusable-django-app.html</link><pubDate>Fri, 05 May 2017 21:43:47 +0000</pubDate><atom:modified>Fri, 05 May 2017 21:43:47 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/how-to-build-reusable-django-app.html</guid><description>The team I work on is responsible for SaaS development and carries almost all of the center&amp;rsquo;s SaaS needs. Among these there are long-term maintenance projects and short-term crunch demo projects, and everyone wears several hats. Of course, the development platform is also open to other people to use, and the whole platform has hundreds if not thousands of SaaS applications.</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>Management</category><category>R&amp;D</category><category>Architecture</category></item><item><title>Dive Into Python</title><link>https://www.chenshaowen.com/en/blog/book/dive-into-python.html</link><pubDate>Fri, 24 Feb 2017 13:11:11 +0000</pubDate><atom:modified>Fri, 24 Feb 2017 13:11:11 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/book/dive-into-python.html</guid><description>Author: Mark Pilgrim
Publisher: Apress
Published: 2004-07-19
ISBN: 9781590593561</description><dc:creator>微信公众号</dc:creator><category>Books</category><category>Python</category><category>Learning</category><category>Programming</category><category>Reading</category></item><item><title>Drawing Fractals with Python: Koch Curves, Julia Sets, and Mandelbrot Sets</title><link>https://www.chenshaowen.com/en/blog/drawing-2d-fractal-graph-using-python.html</link><pubDate>Wed, 25 Jan 2017 23:28:00 +0000</pubDate><atom:modified>Wed, 25 Jan 2017 23:28:00 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/drawing-2d-fractal-graph-using-python.html</guid><description>1. Koch Curve The Swedish mathematician Helge von Koch proposed the Koch curve in his 1904 paper &amp;ldquo;On a continuous curve without tangents, constructible from elementary geometry.&amp;rdquo; It is described as follows: Specify the length of a line segment \(l\) (this can be thought of as iteration 0) Divide this</description><dc:creator>微信公众号</dc:creator><category>Python</category><category>Math</category><category>R&amp;D</category><category>Fractal</category><category>Learning</category><category>Visualization</category><category>Drawing</category></item><item><title>Permission Control in Django</title><link>https://www.chenshaowen.com/en/blog/django-permissions-control.html</link><pubDate>Sun, 22 Jan 2017 09:23:45 +0000</pubDate><atom:modified>Sun, 22 Jan 2017 09:23:45 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/django-permissions-control.html</guid><description>1. Django Built-in Permission Management 1.1 Permission Categories Permission Used to define User A&amp;rsquo;s permission on Task. User If User A has permission on Model B, then User A has the corresponding permission on all instances in Model B. The user_permission field of the User object is used to manage</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Development</category><category>Permissions</category><category>Python</category><category>R&amp;D</category><category>Learning</category><category>Security</category><category>RBAC</category><category>Authentication</category></item><item><title>Several Methods of Django Data Migration (with Code)</title><link>https://www.chenshaowen.com/en/blog/several-methods-of-django-data-migration.html</link><pubDate>Tue, 17 Jan 2017 23:29:15 +0000</pubDate><atom:modified>Tue, 17 Jan 2017 23:29:15 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/several-methods-of-django-data-migration.html</guid><description>1. Background In the course of Web development, migrating data between multiple environments (local, testing, and production) comes up often. This article mainly discusses the possible data migration paths involved in Django development, and seeks feasible methods for them. 2. Scenarios There are four data migration targets in total: the</description><dc:creator>微信公众号</dc:creator><category>Django</category><category>Python</category><category>Data</category><category>Migration</category><category>R&amp;D</category></item><item><title>Getting Started with Character Encoding in Python</title><link>https://www.chenshaowen.com/en/blog/python-coding.html</link><pubDate>Tue, 08 Nov 2016 20:21:42 +0000</pubDate><atom:modified>Tue, 08 Nov 2016 20:21:42 +0000</atom:modified><guid>https://www.chenshaowen.com/en/blog/python-coding.html</guid><description>Background: I had just finished a Django data-query web project. The data came from internal API queries, and every query had to call several APIs to fetch the data and render it on the front-end page. Since the relevant data does not change often, I designed a cache to improve</description><dc:creator>微信公众号</dc:creator><category>Python</category><category>Encoding</category><category>R&amp;D</category><category>Learning</category></item></channel></rss>