Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Các thuộc tính cơ bản của form và field
Form ràng buộc và không ràng buộc Một thực thể Form có thể bị ràng buộc với tập dữ liệu hoặc không bị ràng buộc. Nếu nó bị ràng buộc với một tập dữ liệu, nó có khả năng xác thực dữ liệu này và render như một HTML form có hiển thị dữ liệu. Nếu không ... -
Làm việc với form trong Django
Trừ khi bạn dự định xây dựng các trang web và ứng dụng không làm gì khác ngoài xuất bản nội dung và không chấp nhận đầu vào từ khách truy cập của bạn, bạn sẽ cần phải hiểu và sử dụng các form. Django cung cấp một loạt các công cụ và thư viện giúp bạn... -
What's the Best Thing about Working for Octopus Energy?
On November 16, 2020, I started my first day of employment at Octopus Energy. Here's why I love working there. The Tech Stack The entire tech stack is built on things I know. Python, Django, AWS, and modern JavaScript frameworks. It's been implemented in a very solid way, managing to be both conservative in approach yet innovative in design. While my previous experience has proven useful, I've had the chance to learn new and exciting things. Examples of things I've learned: Hashistack on AWS React & Next.js Yet when I think about it, the tech stack isn't the best thing about working for Octopus. I can find the same tech stack in a thousand other organizations. The People It's always a delight to work with bright, positive-minded people who share your excitement for a job or cause. I like being around people who know things I do not, for no other reason than I can learn by osmosis. I enjoy being around them, and can't wait to meet them as the pandemic fades away. I also am amazed by the same treatment across different groups within the organization. No group or division is looked down on, be they software engineering, … -
Quản lý file tĩnh trong Django
django.contrib.staticfiles thu thập các file tĩnh từ mỗi ứng dụng của bạn (và bất cứ nơi nào khác mà bạn chỉ định) vào một vị trí duy nhất có thể dễ dàng phục vụ khi triển khai dự án lên máy chủ. Các cài đặt STATIC_ROOT Mặc định: None Đường dẫn tuy... -
Class-Based Views(CBV) vs Function Based Views(FBV) in Django
When exploring the views file in a Django project, it might seem difficult for a beginner to decide whether to use the Class-Based Views or the Function Based Views. In this article, I will try to deliver the differences between these two. NOTE: Fo... -
Learning Backend WebDev, Log #3 - Cross Site Request Forgery
Wasn’t quite well today, so took it slow. Read more… (1 min remaining to read) -
Learning Backend WebDev, Log #3 - Cross Site Request Forgery
Wasn’t quite well today, so took it slow. Read more… (2 min remaining to read) -
Các hành động trong Django Admin
Quy trình làm việc cơ bản trong Django Admin là "chọn một đối tượng, sau đó thay đổi nó". Tuy nhiên nếu bạn cần thực hiện cùng một thay đổi cho nhiều đối tượng cùng lúc, quy trình làm việc này có vẻ khá tẻ nhạt. Trong những trường hợp này, Django Adm... -
Sử dụng AdminSite cơ bản
Toàn bộ trang quản trị của Django được biểu diễn bởi một thực thể của django.contrib.admin.sites.AdminSite; mặc định, một thực thể của lớp này đã được tạo là django.contrib.admin.site và bạn có thể sử dụng nó làm AdminSite mặc định để đăng ký các mod... -
Django: How to Set-Up Environmental Variable
What is an Environment variable? For Django projects or apps, An Environment variable is a value that can affect the running processes of a Django app. They are part of the dependencies that initiates enable the continuous running of a Django App. En... -
So you messed up. Now what?
You’ve made and committed to a timeline, but your estimate was wrong. The timeline’s going to slip. Now what? -
What's the best thing about working for Octopus Energy?
On November 16, 2020, I started my first day of employment at Octopus Energy. Here's why I love working there. The Tech Stack The entire tech stack is built on things I know. Python, Django, AWS, and modern JavaScript frameworks. It's been implemented in a very solid way, managing to be both conservative in approach yet innovative in design. While my previous experience has proven useful, I've had the chance to learn new and exciting things. Examples of things I've learned: Hashistack on AWS React & Next.js Yet when I think about it, the tech stack isn't the best thing about working for Octopus. I can find the same tech stack in a thousand other organizations. The People It's always a delight to work with bright, positive-minded people who share your excitement for a job or cause. I like being around people who know things I do not, for no other reason than I can learn by osmosis. I enjoy being around them, and can't wait to meet them as the pandemic fades away. I also am amazed by the same treatment across different groups within the organization. No group or division is looked down on, be they software engineering, … -
What's the best thing about working for Octopus Energy?
On November 16, 2020, I started my first day of employment at Octopus Energy. Here's why I love working there. The Tech Stack The entire tech stack is built on things I know. Python, Django, AWS, and modern JavaScript frameworks. It's been implemented in a very solid way, managing to be both conservative in approach yet innovative in design. While my previous experience has proven useful, I've had the chance to learn new and exciting things. Examples of things I've learned: Hashistack on AWS React & Next.js Yet when I think about it, the tech stack isn't the best thing about working for Octopus. I can find the same tech stack in a thousand other organizations. The People It's always a delight to work with bright, positive-minded people who share your excitement for a job or cause. I like being around people who know things I do not, for no other reason than I can learn by osmosis. I enjoy being around them, and can't wait to meet them as the pandemic fades away. I also am amazed by the same treatment across different groups within the organization. No group or division is looked down on, be they software engineering, … -
What's the best thing about working for Octopus Energy?
On November 16, 2020, I started my first day of employment at Octopus Energy. Here's why I love working there. The Tech Stack The entire tech stack is built on things I know. Python, Django, AWS, and modern JavaScript frameworks. It's been implemented in a very solid way, managing to be both conservative in approach yet innovative in design. While my previous experience has proven useful, I've had the chance to learn new and exciting things. Examples of things I've learned: Hashistack on AWS React & Next.js Yet when I think about it, the tech stack isn't the best thing about working for Octopus. I can find the same tech stack in a thousand other organizations. The People It's always a delight to work with bright, positive-minded people who share your excitement for a job or cause. I like being around people who know things I do not, for no other reason than I can learn by osmosis. I enjoy being around them, and can't wait to meet them as the pandemic fades away. I also am amazed by the same treatment across different groups within the organization. No group or division is looked down on, be they software engineering, … -
What's the best thing about working for Octopus Energy?
On November 16, 2020, I started my first day of employment at Octopus Energy. Here's why I love working there. The Tech Stack The entire tech stack is built on things I know. Python, Django, AWS, and modern JavaScript frameworks. It's been implemented in a very solid way, managing to be both conservative in approach yet innovative in design. While my previous experience has proven useful, I've had the chance to learn new and exciting things. Examples of things I've learned: Hashistack on AWS React & Next.js Yet when I think about it, the tech stack isn't the best thing about working for Octopus. I can find the same tech stack in a thousand other organizations. The People It's always a delight to work with bright, positive-minded people who share your excitement for a job or cause. I like being around people who know things I do not, for no other reason than I can learn by osmosis. I enjoy being around them, and can't wait to meet them as the pandemic fades away. I also am amazed by the same treatment across different groups within the organization. No group or division is looked down on, be they software engineering, … -
Sử dụng ModelAdmin trong Django
Đăng ký một model có sử dụng ModelAdmin ModelAdmin là class biểu diễn một model trong Django Admin. Thường chúng được lưu trong file có tên admin.py trong ứng dụng. Hãy xem một ví dụ về ModelAdmin: from django.contrib import admin from .models import... -
Django project vs app
There is a lot of confusion when newcomers try to understand Django definition of an ‘App’ . In this post we’ll examine the Three major concepts of Django architecture. Project Apps Third party packages Project A Django project is your entire appli... -
Learning Backend WebDev, Log #2
I miss writing about what I learn. So I am going to try and begin again. Read more… (2 min remaining to read) -
Learning Backend WebDev, Log #1
test -
Chapter 11: Form Fundamentals
Sometimes in theclean(), cleanFOO() or save() methods of a Django form, we need to have additional form instance attributes available. A sample case for this is having the request.userobject available. Here is a simple taster-driven example. -
One Database Transaction Too Many
Have you ever wondered how bugs are born? I'm not talking about the trivial kind you can catch with simple unit testing. I'm talking about bugs that may not be apparent on first sight, but are so obvious in retrospect. This is a story about how I accidentally sent hundreds of users messages they got paid when they didn't! What it feels like when you realized you made a mistakeIllustration by Milica Vezmar Basara Table of Contents The Story Creating a Payout Sending Notifications Working in Bulk The Bug Nested Transactions Remedies Assert Atomic Block Durable Transaction Sending Signal on Commit Using a Queue Testing Testing with Django Testing with Pytest Thoughts on Django Signals The Story We have a process in the system where we pay out money to merchants and other types of users. The payout process is a pretty big deal for most users because this is how they get paid. Creating a Payout To facilitate the payout process we have a Django model called PayoutProcess. To create a new payout we use a function that looks roughly like this: from __future__ import annotations from django.db import model, transaction as db_transaction class PayoutProcess(models.Model): #... fields @classmethod def … -
Tổng quan về xác thực người dùng trong Django
Django đi kèm với hệ thống xác thực người dùng. Nó xử lý các tài khoản người dùng, các nhóm người dùng, quyền và phiên làm việc của người dùng dựa trên cookie. Tổng quan Hệ thống xác thực của Django xử lý các xác thực và ủy quyền người dùng. Xác thực... -
Mvt Pattern Of Django
In this post, we will discuss the MVT pattern on Django. The MVT (Model View Template) is a software design pattern. It is a collection of three important components Model View and Template. Although Django follows the MVC pattern but maintains its o... -
Backend Engineer Interview Script
Dwight Schrute, Assistant *to* the Regional Manager. Dunder Mifflin Inc. Credit: NBC. Last month I’ve written a post with Django-specific interview questions. That post is about verifying a candidate’s depth of knowledge with Django. This post is about less specific questions I ask a candidate. Before proceeding to the Django specific ones. If I do proceed after all. In case the candidate does not have any Django-specific experience, what’s the point? These questions do not look for specific answers. Rather the aim is to open up a discussion. So the questions are more in the form of how or why rather than what. And no. How do you describe yourself? is not one of these questions. If you ever get that question, the only correct answer is that by Dwight Schrute as shown above. The questions in this article revolve around: improving web application response time designing authentication handling asynchronous work / task queues HTTP REST API design 1. Server response time Q: In the context a dynamic “data driven” web application, how would you decrease a page’s response time? Asking this should allow the candidate to come up with multiple answers. Among the common answers you should note the … -
How to test a Django ModelForm
What is a ModelForm in Django? ModelForm in Django is a convenient abstraction for creating HTML forms tied to Django models. Consider the following Django model: from django.db import models from django.contrib.auth.models import User class Invoice(models.Model): class State(models.TextChoices): PAID = "PAID" UNPAID = "UNPAID" CANCELLED = "CANCELLED" user = models.ForeignKey(to=User, on_delete=models.PROTECT) date = models.DateField() due_date = models.DateField() state = models.CharField(max_length=15, choices=State.choices, default=State.UNPAID) def __str__(self): return self.user.email To create a form for this model so that we can save and edit invoices in a view, we can subclass ModelForm as follows: from django import forms from .models import Invoice class InvoiceForm(forms.ModelForm): class Meta: model = Invoice fields = ["user", "date", "due_date", "state"] Here we create an InvoiceForm tied to Invoice. This form will expose the following fields in the form: user date due_date state Once we create a ModelForm, we can use it in creation/editing Django views. For an example of the usage, check out the documentation. In this post we focus only on testing the form without interacting with the view layer. (For an example test of a form in the context of a view see Testing an inline formset in Django) How to test a Django ModelForm Testing the …