Category: Django

66 posts
Django
2025-03-13 09:25 (20 months ago)
How to Fix Display Issues in Django Admin Inlines After Upgrading to 5.1

Hide a specific `ModelForm` field in a Django 5 Admin Inline while still passing initial values as a dict — combine `formfield_overrides` with `get_initial`.

Django
2024-12-14 04:46 (23 months ago)
Return Login and Redirect Views by Hardcoding Social Account Provider in django-allauth (When Using AWS Cognito, etc.)

How to Create a Login View in Django Allauth Without Specifying the Social Account Backend in the URL

Django
2024-04-15 08:35 (2 years ago)
After Upgrading to Django 5 and Updating Dependencies, SSL: CERTIFICATE_VERIFY_FAILED Error Occurs When Sending Emails

I updated Django to version 5.0 and also updated other libraries. When I executed the code for sending an email, an ssl.SSLCertVerificationError occurred.

DjangoPython
2024-03-28 00:41 (2 years ago)
The "first" and "second" Arguments of assertEqual in Django's Unit Tests are Actually "expected" and "actual"

When looking at the assertEqual method in Django's unit tests, the first argument is named 'first' and the second argument is named 'second'. It appears that there is no difference in the usage of these variables.

DjangoPython
2024-03-24 04:53 (2 years ago)
Fix: pipenv install fails with AttributeError: module 'pkgutil' has no attribute 'ImpImporter' (Python 3.12)

pipenv install throws "AttributeError: module 'pkgutil' has no attribute 'ImpImporter'" on Python 3.12. Run `python3 -m ensurepip --upgrade` in both the global and virtualenv, or rebuild the pipenv environment.

DjangoPython
2023-11-09 03:39 (3 years ago)
Fix: symbol not found in flat namespace '_mysql_affected_rows' when importing MySQLdb on Apple Silicon

Fix `symbol not found in flat namespace '_mysql_affected_rows'` when importing MySQLdb in Python — rebuild mysqlclient against the right MySQL client library.

Django
2023-10-12 12:41 (3 years ago)
Switching the Logged-in User in Django Using the Django Shell

Here's an overview in English: How to change the user of an already established session using the Django shell. Please do not attempt this in a production environment as it can be dangerous.

Django
2022-12-27 10:15 (3 years ago)
View the Contents of Redis Directly from the Terminal in Django

This article explains how to directly view the contents of Django Redis using the Django shell.

Django
2022-11-18 10:16 (3 years ago)
Reading DB Settings from Django Configuration and Copying Data from Production to Staging with mysqldump

I usually write data copy scripts in bash, but I tried writing one in Python this time and decided to document it.

Django
2022-11-02 12:34 (4 years ago)
Code to Display the Number of URLs in Django

During an IT audit, it was necessary to represent the scale of the application. To achieve this, I decided to consider the total number of URLs in Django as an indicator of the application's scale.

Django
2022-10-17 11:24 (4 years ago)
Manually Creating a Password Reset URL in Django AllAuth

Build a macOS Service (Quick Action) that sends `find` results to the clipboard via `pbcopy` — works back to Big Sur.

Django
2022-09-16 10:11 (4 years ago)
After Updating Django, Migration Fails for oauth2_provider

Use `mkdir -p ... && cd $_` on macOS to chain create-and-enter reliably without race conditions.

Django
2022-09-12 12:21 (4 years ago)
Setting Up a Logger to Output Logs to the Console in Django

Summary of the blog post in English: "Django Logging Configuration: Output to Console Instead of File"

DjangoMySQL
2022-09-11 09:58 (4 years ago)
Tips for Solving the 2027 Malformed Packet Error in MySQL

Return a common post-login redirect target in Django Allauth without specifying a SocialAccount — how `LOGIN_REDIRECT_URL` behaves and how to override it.

DjangoDockerPython
2022-09-03 11:03 (4 years ago)
Changed Django's Docker Environment from Alpine + uWSGI to Debian + Daphne → Ended up with uvicorn After All

Why switch a Django Docker image from Alpine + uWSGI to Debian + Daphne (ASGI), with example Dockerfile and Kubernetes manifest changes.

Django
2022-08-06 02:09 (4 years ago)
Display a Warning When Attempting to Navigate Away with Unsaved Changes in Django Mezzanine's TinyMCE

If you are using version 4 of tinyMCE, you can add an onChange event in the setup option of tinyMCE.init.

Django
2022-03-21 08:57 (4 years ago)
To Create a Request in Django Unit Tests, Retrieving the wsgi_request from the Response is Convenient

When creating unit tests in Django, there are times when you need a Request (WSGIRequest).

Django
2021-12-11 13:51 (4 years ago)
If you see "cannot import name 'ugettext_lazy'" in Django, Django 4.0 might be installed

Here is the solution for resolving the ImportError: cannot import name 'ugettext_lazy' from 'django.utils.translation' that occurs when running manage.py hoge in Django.

DjangoMySQL
2021-11-14 11:10 (5 years ago)
I removed NO_ENGINE_SUBSTITUTION because I got 'Lost connection to MySQL server during query' in Django

If a Django MySQL connection still hits 'No DB engine substitution' despite setting `ENGINE` to `django.db.backends.mysql`, here is the root cause and fix.

Django
2021-01-26 08:21 (5 years ago)
I want to add custom HTML to Django Admin Inlines

Insert a custom HTML snippet or help text into a Django Admin Inline formset (TabularInline / StackedInline) — implementation patterns.