django

403-Forbidden: When Nginx Accesses Static Resource Files (Css,Js,Images)

Bellow are four possibilities you should check to solve this problem. ## 1 check ports There …

robot18 created at July 21, 2021, 11:29 a.m.

Introduction To Various Usages Of Django Model Update

## Model update general usage If our table structure is like this ```plaintext class User(mo…

robot18 created at July 17, 2021, 5:07 p.m.

Specifying A Namespace In Include() Without Providing An App_Name Is Not Supported

## error message ```plaintext File "I:\xx\urls.py", line 22, in <module> url('', include('…

robot18 created at July 17, 2021, 4:57 p.m.

Django Staticfiles App Static File Handling/Reference

In the use of django development, it is inevitable that you will always encounter the processing of…

robot18 created at July 17, 2021, 4:53 p.m.

Django Advanced Usage Form Specifies Field Validation Data

At work, you will encounter that the data filled in the form needs to be verified separately. This …

robot18 created at July 17, 2021, 4:49 p.m.

Django.Urls.Exceptions.Noreversematch: 'Xxx' Is Not A Registered Namespace

## environment * django== 2.1.1 * Render url in html **xx.html** ```plaintext <a hre…

robot18 created at July 17, 2021, 4:46 p.m.

Django Django-Registration Automated Registration

## Install `django-registration` ```plaintext pip install django-registration ``` **note**:…

robot18 created at July 17, 2021, 4:43 p.m.

Get The Requested Url From Django Request

django request Get the requested URL * `request.get_host()`: Get the request address * `req…

robot18 created at July 17, 2021, 4:37 p.m.

Optimization/Solution For Problem That Django Pagination Extraction Speed Is Too Slow

## Introduction Fast paging can be achieved in django, but when the data reaches several million…

robot18 created at July 17, 2021, 4:15 p.m.

How To View The Sql Statements Executed By Django Orm

Django ORM encapsulates database operations quite well, and most of the daily database operations c…

robot18 created at July 17, 2021, 1:38 p.m.

Database Access Optimization In Django-Pre-Loading Related Data

## Introduction Django's model layer provides an ORM system, which allows us to use the database…

robot18 created at July 17, 2021, 1:34 p.m.

Enable Django Applications Of Different Ports On The Same Server To Be Opened On The Same Browser

## Brief introduction When we visit a django website for the first time, django will generate a …

robot18 created at July 17, 2021, 1:17 p.m.

Django Url Parameter Alias Writing

Django **url** parameter alias writing use url ```plaintext from django.conf.urls import url u…

robot18 created at July 17, 2021, 1:12 p.m.

Django Dynamically Creates Multiple Table Names Of A Model And Operates Them Through Django Orm

Create tables dynamically and operate them through Django ORM. ## Dynamically create tables D…

robot18 created at July 17, 2021, 1:10 p.m.

How To Use Stream Response To Process Video In Django

## description Use the `<video>` tag of html5 to play: ```plaintext <video width="320" heigh…

robot18 created at July 17, 2021, 1:03 p.m.

The Value Obtained By Django Request.Session.Session_Key Is None

## description The value obtained by `django request.session.session_key` is `None`. ## solut…

robot18 created at July 17, 2021, 11:20 a.m.

Django Error:Typeerror: __Init__() Missing 1 Required Positional Argument: 'Strategy'

## environment * django version: 2.1.0 * The social\_django module is used. ## descripti…

robot18 created at July 17, 2021, 11:17 a.m.

Django Error: Valueerror: Circular Reference Detected

## detailed error message ```plaintext File "C:\Python27\MyDjango\jianzhi_002\jianzhi_app\views…

robot18 created at July 17, 2021, 11:12 a.m.

Selenium.Common.Exceptions.Webdriverexception: Message: Invalid Argument: Missing 'Name'

Use selenium to add a cookie prompt error: ```plaintext Traceback (most recent call last): F…

robot18 created at July 17, 2021, 11:03 a.m.

How To Use Django-Apscheduler To Perform Timing Tasks In Django

## Install package ```plaintext pip install django-apscheduler ``` ## usage 1\. Modify t…

robot18 created at July 17, 2021, 10:57 a.m.

Django Model Layer (Database) Connection Processing Logic

**Django model layer (database) connection processing logic:** 1. Use `CONN_MAX_AGE` configurat…

robot18 created at July 17, 2021, 10:53 a.m.

Django Connectionerror: Error 104 While Writing To Socket. Connection Reset By Peer

`django ConnectionError: Error 104 while writing to socket` Connection reset by peer: ```plainte…

robot18 created at July 17, 2021, 10:46 a.m.

Unicodedecodeerror: 'Gbk' Codec Can't Decode Byte 0xa6 In Position 9737: Illegal Multibyte Sequence

Background: django == 2.2 ```plaintext Traceback (most recent call last): File "D:\software\…

robot18 created at July 17, 2021, 10:44 a.m.

Django.Db.Utils.Notsupportederror: Renaming The 'Apps_Article' Table While In A Transaction Is Not Supported On Sqlite

## description In the test project, the database: sqlite, an error is prompted when the table na…

robot18 created at July 17, 2021, 10:42 a.m.

How To Use Sql Statement To Query And Return Dictionary Results In Django

## Introduction In Django, some of the more complex methods are not suitable for using orm, and …

robot18 created at July 17, 2021, 10:39 a.m.

Django.Core.Exceptions.Improperlyconfigured: Mysqlclient 1.3.13 Or Newer Is Required; You Have 0.9.3.

## environment * python3.6 * django=2.2 ## reason When django connects to mysql, MySQ…

robot18 created at July 17, 2021, 10:32 a.m.

Valueerror: Dependency On App With No Migrations: Apps

## environment * python3.6 * django=2.2 In case of accidental situation, the file in mig…

robot18 created at July 17, 2021, 9:48 a.m.

Django Randomly Extracts Data From A Specified Table In The Database

Django randomly extracts data from the specified table in the specified database ## method 1: us…

robot18 created at July 17, 2021, 9:44 a.m.

How To Get The Parameters In Request.Get And Request.Post Django

This article mainly explains how to get the parameters in request.GET and request.POST ## get pa…

robot18 created at July 17, 2021, 9:38 a.m.

How To Get The Current Url In The Django Template

In actual development, it is often necessary to get the current URL in the template. The method of …

robot18 created at July 17, 2021, 9:33 a.m.

How Does Django Get The User's Ip Address

In the actual django development process, sometimes it is necessary to record the user's ip informa…

robot18 created at July 17, 2021, 9:30 a.m.

What Is The Difference Between Django Pk And Id And How To Use?

## Introduction If not explicitly specified, by default id is the name of the field created as t…

robot18 created at July 17, 2021, 9:24 a.m.

Django Converts Queryset (Serialization Of Model Instance) To A Dictionary (Json) Method

There are many documents on how to serialize a model query set, but how to serialize the fields of …

robot18 created at July 17, 2021, 9:17 a.m.

Django.Core.Exceptions.Fielderror: 'Pub_Date' Cannot Be Specified For Article Model Form As It Is A Non-Editable Field

## Introduction In django development, an error is prompted when using django form: ```plaint…

robot18 created at July 17, 2021, 9:13 a.m.

How To Filter Dates In Django Orm And Get Data Of A Specified Date Range / Filter Gte And Lte

In the actual application of Django, it is often necessary to extract the data within the specified…

robot18 created at July 17, 2021, 5:21 a.m.

Xadmin Modulenotfounderror: No Module Named 'Django.Contrib.Formtools'

When using virtualenv (virtual environment) to run Xadmin to run /makemigrations, an error message …

robot18 created at July 17, 2021, 5:08 a.m.

Typeerror: In Order To Allow Non-Dict Objects To Be Serialized Set The Safe

Using JsonResponse to return data encountered an error in development: ```plaintext TypeError: …

robot18 created at July 17, 2021, 5:01 a.m.

How To Replace Sum Statement In Django Sql Statement With Sum Query In Django

## Introduction I have a query similar to the following: ```plaintext SELECT SUM(ISNULL(tabl…

robot18 created at July 17, 2021, 4:58 a.m.

How To Create A Custom 404/500 Error Page In Django

Add your own custom implementation of the following two views under views.py under your main conten…

robot18 created at July 17, 2021, 4:54 a.m.

Django Receiving Custom Request Headers (Headers) Detailed

## Introduction Using Django as the backend, the client requests data from Django. In order to d…

robot18 created at July 17, 2021, 4:49 a.m.

How To Find The Union Of Two Query Sets (Queryset) In Django?

I have a Django model with two custom manager methods. Each object will be based on different attri…

robot18 created at July 17, 2021, 4:44 a.m.

Why Should We Use Count() Instead Of Len() For Queryset In Django

## Introduction In Django, suppose I want to iterate and print the resulting QuerySet, what is t…

robot18 created at July 17, 2021, 4:38 a.m.

Django Counts The Number Of Articles By Year And Month, Optimizes Sql Statements And Increases The Speed By 30 Times

## problem Using the Django Debug Toolbar, I found that the sql statement to count the number of…

robot18 created at July 17, 2021, 4:27 a.m.

How To Call Django Environment In A Python Script

Call the Django environment in a Python script: ```plaintext import os if __name__ =='__main…

robot18 created at July 17, 2021, 4:18 a.m.

Django Foreignkey Setting Allows To Be Empty

django ForeignKey (foreign key) setting allows to be empty for example ```plaintext class Wr…

robot18 created at July 16, 2021, 6 p.m.

Django3 Refused To Display 'Url' In A Frame Because It Set 'X-Frame-Options' To 'Deny'

## background When using django3 for development, because the project front-end page uses the if…

robot18 created at July 16, 2021, 5:57 p.m.

Django One App Corresponds To Multiple Databases (One App Multiple Databases) Connect Multiple Databases Settings

## background Due to project requirements, development is carried out in an embedded environment…

robot18 created at July 16, 2021, 5:47 p.m.

Django Error:Ipaddressfield Has Been Removed Except For Support In Historical Migrations

## background When using django to create a model, use `model.IPAddressField` to create a field.…

robot18 created at July 16, 2021, 5:46 p.m.

How To Check Sql Statement Generated For Model And Reverse Generation Model Of Existing Table In Django

## from model to sql statement ### Django 1.9 and below versions: ```plaintext python manage…

robot18 created at July 16, 2021, 5:43 p.m.

How To Use Uuid Instead Of Id As The Primary Key Primary In Django

Whenever we create any new model, an ID field is appended. By default, the data type of the ID fiel…

robot18 created at July 16, 2021, 5:37 p.m.

How To Get Equivalent Sql Statement Corresponding To Django Orm

Sometimes you want to know how Django ORM makes our queries execute, or what the SQL corresponds to…

robot18 created at July 16, 2021, 5:36 p.m.

Django Orm Between And Usage

Django ORM between and usage ## sql statement ```plaintext SELECT * FROM target WHERE ctime …

robot18 created at July 16, 2021, 5:32 p.m.

Django Orm Uses Sql Statement To Perform Multi-Table Joint Query (Join On, Left Join)

## background Because the use of `Manager.raw ()` can not meet the needs of executing SQL statem…

robot18 created at July 16, 2021, 5:30 p.m.

Fielddoesnotexist: Raw Query Must Include The Primary Key

## environment * python3.7 * django 3.1 Use `model.object.raw(sql)` in django  triggered…

robot18 created at July 16, 2021, 5:24 p.m.

Unorderedobjectlistwarning: Pagination May Yield Inconsistent Results With An Unordered Object_List

## Django paging warning prompt ```plaintext UnorderedObjectListWarning: Pagination may yield i…

robot18 created at July 16, 2021, 5:21 p.m.

Django Attributeerror: Generic Detail View Xxx Must Be Called With Either An Object Pk Or A Slug In The Urlconf

## Introduction Using DetailView, prompt error: ```plaintext AttributeError: Generic detail …

robot18 created at July 16, 2021, 5:18 p.m.

Django Sitemap Generation Detailed Explanation And Optimization For Map-Too-Big Problem

## Introduction A sitemap is a container for all links on a website. Many websites have deep con…

robot18 created at July 16, 2021, 5:02 p.m.

The Difference Between Django Null=True And Blank=True

## Introduction It is important to understand that the options in the Django model field definit…

robot18 created at July 16, 2021, 4:41 p.m.

Carrying Parameters When Django Uses Paginate For Paging

In django, when using paging, the paging URL needs to carry parameters, such as: ```plaintext h…

robot18 created at July 16, 2021, 4:30 p.m.

Django: Query Certain Number Of Objects

## limiting QuerySets In django's official document, the method to query limited number of objec…

robot18 created at July 16, 2021, 4:15 p.m.

Django.Core.Exceptions.Improperlyconfigured: Mysqlclient 1.4.0 Or Newer Is Required; You Have 0.10.1.

## environment * python=3.8 * django=3.1 ## error message ```plaintext django.core.e…

robot18 created at July 16, 2021, 2:52 p.m.

Django: How To Uses Bulk_Create (Batch Creation) To Get The Id After Successful Creation

## environment Django: how to uses bulk\_create (batch creation) to get the id after successful …

robot18 created at July 16, 2021, 7:56 a.m.

Django: Corsheaders Solve Cross-Domain Problems

## background Front-end and back-end development are separated, and cross-domain problems will i…

robot18 created at July 16, 2021, 7:46 a.m.

Incorrect String Value: ‘\Xf0\X9f\X8c\Xb8’ For Column'xxx' At Row 1, Mysql Storage Of Unusual Characters/Emoticons Error

Solve `Incorrect string value: ‘\xF0\x9F\x8C\xB8’ for column'xxx' at row 1` error caused by storing…

robot18 created at July 15, 2021, 4:59 p.m.

How To Uses Group By To Query Data In Django Orm

if you want to use orm in django to implement the following sql statement functions: ```plaintex…

robot18 created at July 15, 2021, 4:29 p.m.

When Runserver To Start Django, Some Websocket Connections Are Automatically Interrupted

When runserver to start django, some websocket connections are automatically interrupted. ## Err…

robot18 created at July 15, 2021, 4:13 p.m.

Solution For Python Django.Db.Utils.Interfaceerror: (0, '')

## error message ```plaintext django.db.utils.InterfaceError: (0, '') ``` ## Reasons for da…

robot18 created at July 15, 2021, 3:56 p.m.

Django: How To Redirect From Detailview When The Specified Object Does Not Exist?

## Introduction Use the `get_object` method of `DetailView` to trigger `Http404`, if the object …

robot18 created at July 15, 2021, 3:51 p.m.

How To Limits The Number Of Characters/Words In Django Templates

Django uses templates filter to limit the number of characters * If the desired stage is a **s…

robot18 created at July 15, 2021, 3:48 p.m.

How To Filter Out The Html Tags Contained In Strings In Django Templates

how to filter out the html tags contained in strings in django templates. there are two ways: …

robot18 created at July 15, 2021, 3:33 p.m.

Django Form Sets The Default Initial Value

## Introduction Use django, use form in django to format data, individual fields will have a def…

robot18 created at July 15, 2021, 3:20 p.m.

Optimization Method For Too Many Django Sitemap Urls

The optimized code is as follows: ## sitemap.py ```plaintext from django.contrib.sitemaps im…

robot18 created at July 15, 2021, 3:03 p.m.

Django Uses Transcation To Handle Database Transaction Management

## scenes to be used For example, when generating an order, you need to generate multiple data r…

robot18 created at July 15, 2021, 2:57 p.m.

Notes For Server Error 500 During Django Deployment

Sometimes, after deployment, there is no error in the deployment of django blog or website, but whe…

robot18 created at June 25, 2021, 5:27 p.m.

Django Server Error (500) A Solution Because Of Using Ueditor

When debugging the Django project on line, it is found that the Server Error (500) is displayed whe…

robot18 created at June 25, 2021, 4:49 p.m.

Django Error: That Ip Address Can‘T Be Assigned To

## Operating environment: * **System**: Ali Cloud Ubuntu 18.04.3 LTS (GNU / Linux 4.15.0-52-ge…

robot18 created at June 25, 2021, 9:52 a.m.

Oracle.Databaseerror: Ora-00955: Name Is Already Used By An Existing Object

## error description ![](/media/image_WQ2BQna.png) here is the error message: ```plaintext…

robot18 created at June 25, 2021, 8:36 a.m.

Solution: Django-Error: That Port Is Already In Use

For Django newbies, there will be many problems during the learning process, which often encounters…

robot18 created at June 24, 2021, 4:14 p.m.

Django Data Migration 1050 Error: Django.Db.Utils.Internalerror: (1050, "Table 'Xxx' Already Exists")

## Solution Execute this first: ```plaintext python manage.py migrate --fake ``` Then …

robot18 created at June 24, 2021, 10:46 a.m.

Use Django-Hitcount To Count Hits/Views Of Django Project

The [django-hitcount](https://pypi.org/project/django-hitcount/) package is very useful for countin…

lyp created at June 19, 2021, 6:33 p.m.

Celery: Keyerror: 'Djcelery_Email_Send_Multiple'

## description This bug has puzzled me for two days! At first, I am pretty sure I have write the…

lyp created at June 19, 2021, 9:24 a.m.

Daphne: Django.Core.Exceptions.Improperlyconfigured: Requested Setting Installed_Apps, But Settings...

## error description I got this error from my daphne logs after deployment, but I'm sure I have …

lyp created at June 17, 2021, 3:27 a.m.

How To Let Users Login With Google Account In Your Django Website

To allow users login with google account in our django can be easily done by using [django-allauth]…

lyp created at May 27, 2021, 2:54 p.m.

Favicon For Django Website

A beautiful icon would help uses to find our website in their Bookmarks. Here we would talk about d…

lyp created at March 14, 2021, 12:03 p.m.

How To Add Paginations In A Django Project

Paginations are often used in listviews of django projects, such as article list, question list and…

lyp created at March 13, 2021, 7:35 a.m.

Don't Put Favicon.Ico Into {% Compress %}{% Endcompress %}, Or It Won't Show

Interestingly, I found this problem after deploying my django project. Because  the **django-compre…

lyp created at March 12, 2021, 9:25 a.m.

Adding Rel="Nofollow" And Target="_Blank" Attributes To Links In Django Project

After googling for a while for a plugin to automatically  add  `rel="nofollow"` and `target="_blank…

lyp created at March 11, 2021, 2:10 p.m.

Create A Points System For Django Project

This article will show you how to create a **minimal** points/reputation system in our django proje…

robot18 created at March 5, 2021, 3:03 p.m.

Building Django Search App With Elasticsearch-7

elasticsearch is powerful, however, django-haystack only supports old versions of elasticsearch. …

lyp created at March 2, 2021, 3:42 p.m.

Create An Admin Site For Our Django Project

Fortunately, we do not need to do much work to create an admin site for our django project, because…

lyp created at Feb. 27, 2021, 2:27 p.m.

Django: Modulenotfounderror ...... No Module Named 'Admin'

if you got this error in your django project, you could: ## **1 Check your** `settings.py` in…

geoer created at Feb. 27, 2021, 12:26 p.m.

Permissionerror At /Xxx/Yyy/ [Errno 13] Permission Denied: '/..../Media/Profile_Images/Xxx.Jpg'

## **BUG** After finishing deployment of my django blog, I found there is a problem with uploadi…

lyp created at Feb. 26, 2021, 6:18 p.m.